From 1b48e922d4fe190a3499dc7e97a258d210d7cb87 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 14 Jul 2013 16:57:50 -0700 Subject: [PATCH] Add a setup warning for port in `mysql.host` Summary: A pull from GitHub recently added `mysql.port`, for explicitly configuring the MySQL port. See: - https://github.com/facebook/libphutil/pull/27 - https://github.com/facebook/phabricator/pull/356 Add a setup warning for old-style configurations (which will still work properly), to get them to move to the new style. Test Plan: {F50113} Reviewers: btrahan, chad Reviewed By: chad CC: aran Differential Revision: https://secure.phabricator.com/D6449 --- conf/default.conf.php | 2 +- .../check/PhabricatorSetupCheckDatabase.php | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/conf/default.conf.php b/conf/default.conf.php index bc427dcafb..cf9f963d4e 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -174,7 +174,7 @@ return array( 'mysql.host' => 'localhost', // If you want to connect to a different port than the default (which is 3306) - 'mysql.port' => '3306', + 'mysql.port' => null, // Phabricator supports PHP extensions MySQL and MySQLi. It is possible to // implement also other access mechanism (e.g. PDO_MySQL). The class must diff --git a/src/applications/config/check/PhabricatorSetupCheckDatabase.php b/src/applications/config/check/PhabricatorSetupCheckDatabase.php index b0903eabc2..24a2f26a7b 100644 --- a/src/applications/config/check/PhabricatorSetupCheckDatabase.php +++ b/src/applications/config/check/PhabricatorSetupCheckDatabase.php @@ -107,5 +107,36 @@ final class PhabricatorSetupCheckDatabase extends PhabricatorSetupCheck { hsprintf('phabricator/ $ ./bin/storage upgrade')); } } + + + $host = PhabricatorEnv::getEnvConfig('mysql.host'); + $matches = null; + if (preg_match('/^([^:]+):(\d+)$/', $host, $matches)) { + $host = $matches[1]; + $port = $matches[2]; + + $this->newIssue('storage.mysql.hostport') + ->setName(pht('Deprecated mysql.host Format')) + ->setSummary( + pht( + 'Move port information from `mysql.host` to `mysql.port` in your '. + 'config.')) + ->setMessage( + pht( + 'Your `mysql.host` configuration contains a port number, but '. + 'this usage is deprecated. Instead, put the port number in '. + '`mysql.port`.')) + ->addPhabricatorConfig('mysql.host') + ->addPhabricatorConfig('mysql.port') + ->addCommand( + hsprintf( + 'phabricator/ $ ./bin/config set mysql.host %s', + $host)) + ->addCommand( + hsprintf( + 'phabricator/ $ ./bin/config set mysql.port %s', + $port)); + } + } }