Page MenuHomePhabricator

D16501.diff
No OneTemporary

D16501.diff

diff --git a/src/aphront/configuration/AphrontApplicationConfiguration.php b/src/aphront/configuration/AphrontApplicationConfiguration.php
--- a/src/aphront/configuration/AphrontApplicationConfiguration.php
+++ b/src/aphront/configuration/AphrontApplicationConfiguration.php
@@ -73,13 +73,26 @@
$response = PhabricatorSetupCheck::willPreflightRequest();
if ($response) {
- PhabricatorStartup::endOutputCapture();
- $sink->writeResponse($response);
- return;
+ return self::writeResponse($sink, $response);
}
PhabricatorStartup::beginStartupPhase('env.init');
- PhabricatorEnv::initializeWebEnvironment();
+
+ try {
+ PhabricatorEnv::initializeWebEnvironment();
+ $database_exception = null;
+ } catch (AphrontInvalidCredentialsQueryException $ex) {
+ $database_exception = $ex;
+ } catch (AphrontConnectionQueryException $ex) {
+ $database_exception = $ex;
+ }
+
+ if ($database_exception) {
+ $issue = PhabricatorSetupIssue::newDatabaseConnectionIssue(
+ $database_exception);
+ $response = PhabricatorSetupCheck::newIssueResponse($issue);
+ return self::writeResponse($sink, $response);
+ }
$multimeter->setSampleRate(
PhabricatorEnv::getEnvConfig('debug.sample-rate'));
@@ -111,9 +124,7 @@
$response = PhabricatorSetupCheck::willProcessRequest();
if ($response) {
- PhabricatorStartup::endOutputCapture();
- $sink->writeResponse($response);
- return;
+ return self::writeResponse($sink, $response);
}
$host = AphrontRequest::getHTTPHeader('Host');
@@ -256,31 +267,7 @@
$response = $controller->willSendResponse($response);
$response->setRequest($request);
- $unexpected_output = PhabricatorStartup::endOutputCapture();
- if ($unexpected_output) {
- $unexpected_output = pht(
- "Unexpected output:\n\n%s",
- $unexpected_output);
-
- phlog($unexpected_output);
-
- if ($response instanceof AphrontWebpageResponse) {
- echo phutil_tag(
- 'div',
- array(
- 'style' =>
- 'background: #eeddff;'.
- 'white-space: pre-wrap;'.
- 'z-index: 200000;'.
- 'position: relative;'.
- 'padding: 8px;'.
- 'font-family: monospace',
- ),
- $unexpected_output);
- }
- }
-
- $sink->writeResponse($response);
+ self::writeResponse($sink, $response);
} catch (Exception $ex) {
if ($original_exception) {
throw $original_exception;
@@ -291,6 +278,37 @@
return $response;
}
+ private static function writeResponse(
+ AphrontHTTPSink $sink,
+ AphrontResponse $response) {
+
+ $unexpected_output = PhabricatorStartup::endOutputCapture();
+ if ($unexpected_output) {
+ $unexpected_output = pht(
+ "Unexpected output:\n\n%s",
+ $unexpected_output);
+
+ phlog($unexpected_output);
+
+ if ($response instanceof AphrontWebpageResponse) {
+ echo phutil_tag(
+ 'div',
+ array(
+ 'style' =>
+ 'background: #eeddff;'.
+ 'white-space: pre-wrap;'.
+ 'z-index: 200000;'.
+ 'position: relative;'.
+ 'padding: 8px;'.
+ 'font-family: monospace',
+ ),
+ $unexpected_output);
+ }
+ }
+
+ $sink->writeResponse($response);
+ }
+
/* -( URI Routing )-------------------------------------------------------- */
diff --git a/src/applications/config/check/PhabricatorDatabaseSetupCheck.php b/src/applications/config/check/PhabricatorDatabaseSetupCheck.php
--- a/src/applications/config/check/PhabricatorDatabaseSetupCheck.php
+++ b/src/applications/config/check/PhabricatorDatabaseSetupCheck.php
@@ -23,21 +23,17 @@
try {
queryfx($conn_raw, 'SELECT 1');
+ $database_exception = null;
+ } catch (AphrontInvalidCredentialsQueryException $ex) {
+ $database_exception = $ex;
} catch (AphrontConnectionQueryException $ex) {
- $message = pht(
- "Unable to connect to MySQL!\n\n".
- "%s\n\n".
- "Make sure Phabricator and MySQL are correctly configured.",
- $ex->getMessage());
+ $database_exception = $ex;
+ }
- $this->newIssue('mysql.connect')
- ->setName(pht('Can Not Connect to MySQL'))
- ->setMessage($message)
- ->setIsFatal(true)
- ->addRelatedPhabricatorConfig('mysql.host')
- ->addRelatedPhabricatorConfig('mysql.port')
- ->addRelatedPhabricatorConfig('mysql.user')
- ->addRelatedPhabricatorConfig('mysql.pass');
+ if ($database_exception) {
+ $issue = PhabricatorSetupIssue::newDatabaseConnectionIssue(
+ $database_exception);
+ $this->addIssue($issue);
return;
}
diff --git a/src/applications/config/check/PhabricatorSetupCheck.php b/src/applications/config/check/PhabricatorSetupCheck.php
--- a/src/applications/config/check/PhabricatorSetupCheck.php
+++ b/src/applications/config/check/PhabricatorSetupCheck.php
@@ -147,7 +147,7 @@
return null;
}
- private static function newIssueResponse(PhabricatorSetupIssue $issue) {
+ public static function newIssueResponse(PhabricatorSetupIssue $issue) {
$view = id(new PhabricatorSetupIssueView())
->setIssue($issue);
diff --git a/src/applications/config/issue/PhabricatorSetupIssue.php b/src/applications/config/issue/PhabricatorSetupIssue.php
--- a/src/applications/config/issue/PhabricatorSetupIssue.php
+++ b/src/applications/config/issue/PhabricatorSetupIssue.php
@@ -20,6 +20,26 @@
private $originalPHPConfigValues = array();
private $links;
+ public static function newDatabaseConnectionIssue(
+ AphrontQueryException $ex) {
+
+ $message = pht(
+ "Unable to connect to MySQL!\n\n".
+ "%s\n\n".
+ "Make sure Phabricator and MySQL are correctly configured.",
+ $ex->getMessage());
+
+ return id(new self())
+ ->setIssueKey('mysql.connect')
+ ->setName(pht('Can Not Connect to MySQL'))
+ ->setMessage($message)
+ ->setIsFatal(true)
+ ->addRelatedPhabricatorConfig('mysql.host')
+ ->addRelatedPhabricatorConfig('mysql.port')
+ ->addRelatedPhabricatorConfig('mysql.user')
+ ->addRelatedPhabricatorConfig('mysql.pass');
+ }
+
public function addCommand($command) {
$this->commands[] = $command;
return $this;

File Metadata

Mime Type
text/plain
Expires
Tue, Oct 22, 8:34 PM (3 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6742776
Default Alt Text
D16501.diff (6 KB)

Event Timeline