diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -252,7 +252,6 @@ 'AphrontMultipartParser' => 'aphront/multipartparser/AphrontMultipartParser.php', 'AphrontMultipartParserTestCase' => 'aphront/multipartparser/__tests__/AphrontMultipartParserTestCase.php', 'AphrontMultipartPart' => 'aphront/multipartparser/AphrontMultipartPart.php', - 'AphrontMySQLDatabaseConnection' => 'infrastructure/storage/connection/mysql/AphrontMySQLDatabaseConnection.php', 'AphrontMySQLDatabaseConnectionTestCase' => 'infrastructure/storage/__tests__/AphrontMySQLDatabaseConnectionTestCase.php', 'AphrontMySQLiDatabaseConnection' => 'infrastructure/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php', 'AphrontNotSupportedQueryException' => 'infrastructure/storage/exception/AphrontNotSupportedQueryException.php', @@ -6263,7 +6262,6 @@ 'AphrontMultipartParser' => 'Phobject', 'AphrontMultipartParserTestCase' => 'PhutilTestCase', 'AphrontMultipartPart' => 'Phobject', - 'AphrontMySQLDatabaseConnection' => 'AphrontBaseMySQLDatabaseConnection', 'AphrontMySQLDatabaseConnectionTestCase' => 'PhabricatorTestCase', 'AphrontMySQLiDatabaseConnection' => 'AphrontBaseMySQLDatabaseConnection', 'AphrontNotSupportedQueryException' => 'AphrontQueryException', diff --git a/src/applications/config/check/PhabricatorExtensionsSetupCheck.php b/src/applications/config/check/PhabricatorExtensionsSetupCheck.php --- a/src/applications/config/check/PhabricatorExtensionsSetupCheck.php +++ b/src/applications/config/check/PhabricatorExtensionsSetupCheck.php @@ -19,6 +19,7 @@ 'openssl', 'mbstring', 'ctype', + 'mysqli', // There is a tiny chance we might not need this, but a significant // number of applications require it and it's widely available. @@ -32,10 +33,6 @@ } } - if (!extension_loaded('mysqli') && !extension_loaded('mysql')) { - $need[] = 'mysqli or mysql'; - } - if (!$need) { return; } diff --git a/src/applications/config/check/PhabricatorPHPConfigSetupCheck.php b/src/applications/config/check/PhabricatorPHPConfigSetupCheck.php --- a/src/applications/config/check/PhabricatorPHPConfigSetupCheck.php +++ b/src/applications/config/check/PhabricatorPHPConfigSetupCheck.php @@ -67,29 +67,7 @@ ->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". - 'This software 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 php-mysqlnd')); - - $this->newIssue('php.mysqli') - ->setName(pht('MySQLi Extension Not Available')) - ->setSummary($summary) - ->setMessage($message); - } else if (!defined('MYSQLI_ASYNC')) { + if (!defined('MYSQLI_ASYNC')) { $summary = pht( 'Configure the MySQL Native Driver to improve database behavior.'); @@ -112,17 +90,10 @@ ->setMessage($message); } - - if (extension_loaded('mysqli')) { - $infile_key = 'mysqli.allow_local_infile'; - } else { - $infile_key = 'mysql.allow_local_infile'; - } - - if (ini_get($infile_key)) { + if (ini_get('mysqli.allow_local_infile')) { $summary = pht( 'Disable unsafe option "%s" in PHP configuration.', - $infile_key); + 'mysqli.allow_local_infile'); $message = pht( 'PHP is currently configured to honor requests from any MySQL server '. @@ -139,13 +110,16 @@ 'dangerous.'. "\n\n". 'To disable this option, set: %s', - phutil_tag('tt', array(), pht('%s = 0', $infile_key))); + phutil_tag( + 'tt', + array(), + pht('%s = 0', 'mysqli.allow_local_infile'))); - $this->newIssue('php.'.$infile_key) + $this->newIssue('php.mysqli.allow_local_infile') ->setName(pht('Unsafe PHP "Local Infile" Configuration')) ->setSummary($summary) ->setMessage($message) - ->addPHPConfig($infile_key); + ->addPHPConfig('mysqli.allow_local_infile'); } } diff --git a/src/docs/user/installation_guide.diviner b/src/docs/user/installation_guide.diviner --- a/src/docs/user/installation_guide.diviner +++ b/src/docs/user/installation_guide.diviner @@ -120,7 +120,7 @@ - Apache (usually "httpd" or "apache2") (or nginx) - MySQL Server (usually "mysqld" or "mysql-server" or "mariadb-server") - PHP (usually "php") - - Required PHP extensions: mbstring, iconv, mysql (or mysqli), curl, pcntl + - Required PHP extensions: mbstring, iconv, mysqli, curl, pcntl (these might be something like "php-mysql" or "php-mysqlnd") - Optional PHP extensions: gd, zip diff --git a/src/infrastructure/cluster/PhabricatorDatabaseRef.php b/src/infrastructure/cluster/PhabricatorDatabaseRef.php --- a/src/infrastructure/cluster/PhabricatorDatabaseRef.php +++ b/src/infrastructure/cluster/PhabricatorDatabaseRef.php @@ -738,11 +738,7 @@ } public static function newRawConnection(array $options) { - if (extension_loaded('mysqli')) { - return new AphrontMySQLiDatabaseConnection($options); - } else { - return new AphrontMySQLDatabaseConnection($options); - } + return new AphrontMySQLiDatabaseConnection($options); } } diff --git a/src/infrastructure/storage/connection/mysql/AphrontMySQLDatabaseConnection.php b/src/infrastructure/storage/connection/mysql/AphrontMySQLDatabaseConnection.php deleted file mode 100644 --- a/src/infrastructure/storage/connection/mysql/AphrontMySQLDatabaseConnection.php +++ /dev/null @@ -1,160 +0,0 @@ -validateUTF8String($string); - return $this->escapeBinaryString($string); - } - - public function escapeBinaryString($string) { - return mysql_real_escape_string($string, $this->requireConnection()); - } - - public function getInsertID() { - return mysql_insert_id($this->requireConnection()); - } - - public function getAffectedRows() { - return mysql_affected_rows($this->requireConnection()); - } - - protected function closeConnection() { - mysql_close($this->requireConnection()); - } - - protected function connect() { - if (!function_exists('mysql_connect')) { - // We have to '@' the actual call since it can spew all sorts of silly - // noise, but it will also silence fatals caused by not having MySQL - // installed, which has bitten me on three separate occasions. Make sure - // such failures are explicit and loud. - throw new Exception( - pht( - 'About to call %s, but the PHP MySQL extension is not available!', - 'mysql_connect()')); - } - - $user = $this->getConfiguration('user'); - $host = $this->getConfiguration('host'); - $port = $this->getConfiguration('port'); - - if ($port) { - $host .= ':'.$port; - } - - $database = $this->getConfiguration('database'); - - $pass = $this->getConfiguration('pass'); - if ($pass instanceof PhutilOpaqueEnvelope) { - $pass = $pass->openEnvelope(); - } - - $timeout = $this->getConfiguration('timeout'); - $timeout_ini = 'mysql.connect_timeout'; - if ($timeout) { - $old_timeout = ini_get($timeout_ini); - ini_set($timeout_ini, $timeout); - } - - try { - $conn = @mysql_connect( - $host, - $user, - $pass, - $new_link = true, - $flags = 0); - } catch (Exception $ex) { - if ($timeout) { - ini_set($timeout_ini, $old_timeout); - } - throw $ex; - } - - if ($timeout) { - ini_set($timeout_ini, $old_timeout); - } - - if (!$conn) { - $errno = mysql_errno(); - $error = mysql_error(); - $this->throwConnectionException($errno, $error, $user, $host); - } - - if ($database !== null) { - $ret = @mysql_select_db($database, $conn); - if (!$ret) { - $this->throwQueryException($conn); - } - } - - $ok = @mysql_set_charset('utf8mb4', $conn); - if (!$ok) { - mysql_set_charset('binary', $conn); - } - - return $conn; - } - - protected function rawQuery($raw_query) { - return @mysql_query($raw_query, $this->requireConnection()); - } - - /** - * @phutil-external-symbol function mysql_multi_query - * @phutil-external-symbol function mysql_fetch_result - * @phutil-external-symbol function mysql_more_results - * @phutil-external-symbol function mysql_next_result - */ - protected function rawQueries(array $raw_queries) { - $conn = $this->requireConnection(); - $results = array(); - - if (!function_exists('mysql_multi_query')) { - foreach ($raw_queries as $key => $raw_query) { - $results[$key] = $this->processResult($this->rawQuery($raw_query)); - } - return $results; - } - - if (!mysql_multi_query(implode("\n;\n\n", $raw_queries), $conn)) { - $ex = $this->processResult(false); - return array_fill_keys(array_keys($raw_queries), $ex); - } - - $processed_all = false; - foreach ($raw_queries as $key => $raw_query) { - $results[$key] = $this->processResult(@mysql_fetch_result($conn)); - if (!mysql_more_results($conn)) { - $processed_all = true; - break; - } - mysql_next_result($conn); - } - - if (!$processed_all) { - throw new Exception( - pht('There are some results left in the result set.')); - } - - return $results; - } - - protected function freeResult($result) { - mysql_free_result($result); - } - - protected function fetchAssoc($result) { - return mysql_fetch_assoc($result); - } - - protected function getErrorCode($connection) { - return mysql_errno($connection); - } - - protected function getErrorDescription($connection) { - return mysql_error($connection); - } - -}