From 0bf8e33bb6c17e41712dd6f4db11139a850e82cd Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 13 Mar 2018 12:14:36 -0700 Subject: [PATCH] Issue setup guidance recommending MySQLi and MySQL Native Driver Summary: Fixes T12994. We need `MYSQLI_ASYNC` to implement client-side query timeouts, and we need MySQLi + MySQL Native Driver to get `MYSQLI_ASYNC`. Recommend users install MySQLi and MySQL Native Driver if they don't have them. These are generally the defaults and best practice anyway, but Ubuntu makes it easy to use the older stuff. All the cases we're currently aware of stem from `apt-get install php5-mysql` (which explicitly selects the non-native driver) so issue particular guidance about `php5-mysqlnd`. Test Plan: - Faked both issues locally, reviewed the text. - Will deploy to `secure`, which currently has the non-native driver. Maniphest Tasks: T12994 Differential Revision: https://secure.phabricator.com/D19216 --- resources/celerity/map.php | 4 +- scripts/install/install_ubuntu.sh | 2 +- .../check/PhabricatorPHPConfigSetupCheck.php | 45 +++++++++++++++++++ src/docs/user/installation_guide.diviner | 2 +- .../css/application/config/setup-issue.css | 2 +- 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 67ee4aa8e1..769e8dfabe 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -46,7 +46,7 @@ return array( 'rsrc/css/application/conduit/conduit-api.css' => '7bc725c4', 'rsrc/css/application/config/config-options.css' => '4615667b', 'rsrc/css/application/config/config-template.css' => '8f18fa41', - 'rsrc/css/application/config/setup-issue.css' => '7dae7f18', + 'rsrc/css/application/config/setup-issue.css' => '30ee0173', 'rsrc/css/application/config/unhandled-exception.css' => '4c96257a', 'rsrc/css/application/conpherence/color.css' => 'abb4c358', 'rsrc/css/application/conpherence/durable-column.css' => '89ea6bef', @@ -881,7 +881,7 @@ return array( 'releeph-preview-branch' => 'b7a6f4a5', 'releeph-request-differential-create-dialog' => '8d8b92cd', 'releeph-request-typeahead-css' => '667a48ae', - 'setup-issue-css' => '7dae7f18', + 'setup-issue-css' => '30ee0173', 'sprite-login-css' => '396f3c3a', 'sprite-tokens-css' => '9cdfd599', 'syntax-default-css' => '9923583c', diff --git a/scripts/install/install_ubuntu.sh b/scripts/install/install_ubuntu.sh index b3e678450d..5408cdb3e1 100755 --- a/scripts/install/install_ubuntu.sh +++ b/scripts/install/install_ubuntu.sh @@ -45,7 +45,7 @@ set +x sudo apt-get -qq update sudo apt-get install \ $GIT mysql-server apache2 dpkg-dev \ - php5 php5-mysql php5-gd php5-dev php5-curl php-apc php5-cli php5-json + php5 php5-mysqlnd php5-gd php5-dev php5-curl php-apc php5-cli php5-json # Enable mod_rewrite sudo a2enmod rewrite diff --git a/src/applications/config/check/PhabricatorPHPConfigSetupCheck.php b/src/applications/config/check/PhabricatorPHPConfigSetupCheck.php index 5382a27b7a..cf3148b5be 100644 --- a/src/applications/config/check/PhabricatorPHPConfigSetupCheck.php +++ b/src/applications/config/check/PhabricatorPHPConfigSetupCheck.php @@ -67,6 +67,51 @@ final class PhabricatorPHPConfigSetupCheck extends PhabricatorSetupCheck { ->addPHPConfig('always_populate_raw_post_data'); } + if (!extension_loaded('mysqli')) { + $summary = pht( + 'Install the MySQLi extension to improve database behavior.'); + + $message = pht( + 'PHP is currently using the very old "mysql" extension to interact '. + 'with the database. You should install the newer "mysqli" extension '. + 'to improve behaviors (like error handling and query timeouts).'. + "\n\n". + 'Phabricator will work with the older extension, but upgrading to the '. + 'newer extension is recommended.'. + "\n\n". + 'You may be able to install the extension with a command like: %s', + + // NOTE: We're intentionally telling you to install "mysqlnd" here; on + // Ubuntu, there's no separate "mysqli" package. + phutil_tag('tt', array(), 'sudo apt-get install php5-mysqlnd')); + + $this->newIssue('php.mysqli') + ->setName(pht('MySQLi Extension Not Available')) + ->setSummary($summary) + ->setMessage($message); + } else if (!defined('MYSQLI_ASYNC')) { + $summary = pht( + 'Configure the MySQL Native Driver to improve database behavior.'); + + $message = pht( + 'PHP is currently using the older MySQL external driver instead of '. + 'the newer MySQL native driver. The older driver lacks options and '. + 'features (like support for query timeouts) which allow Phabricator '. + 'to interact better with the database.'. + "\n\n". + 'Phabricator will work with the older driver, but upgrading to the '. + 'native driver is recommended.'. + "\n\n". + 'You may be able to install the native driver with a command like: %s', + phutil_tag('tt', array(), 'sudo apt-get install php5-mysqlnd')); + + + $this->newIssue('php.myqlnd') + ->setName(pht('MySQL Native Driver Not Available')) + ->setSummary($summary) + ->setMessage($message); + } + } } diff --git a/src/docs/user/installation_guide.diviner b/src/docs/user/installation_guide.diviner index 8feb8ae1d0..29895eb2a9 100644 --- a/src/docs/user/installation_guide.diviner +++ b/src/docs/user/installation_guide.diviner @@ -123,7 +123,7 @@ Otherwise, here's a general description of what you need to install: - MySQL Server (usually "mysqld" or "mysql-server") - PHP (usually "php") - Required PHP extensions: mbstring, iconv, mysql (or mysqli), curl, pcntl - (these might be something like "php-mysql" or "php5-mysql") + (these might be something like "php-mysql" or "php5-mysqlnd") - Optional PHP extensions: gd, apc (special instructions for APC are available below if you have difficulty installing it), xhprof (instructions below, you only need this if you are developing Phabricator) diff --git a/webroot/rsrc/css/application/config/setup-issue.css b/webroot/rsrc/css/application/config/setup-issue.css index 7ba033d9c2..a80b02815c 100644 --- a/webroot/rsrc/css/application/config/setup-issue.css +++ b/webroot/rsrc/css/application/config/setup-issue.css @@ -84,7 +84,7 @@ } .setup-issue-body { - padding: 16px 16px 0 16px; + padding: 16px; } .setup-issue-status { -- 2.51.2