diff --git a/conf/default.conf.php b/conf/default.conf.php index 977230ead1..b2e06c998b 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -120,6 +120,11 @@ return array( // The number of times to try reconnecting to the MySQL database 'mysql.connection-retries' => 3, + // Phabricator supports PHP extensions MySQL and MySQLi. It is possible to + // implement also other access mechanism (e.g. PDO_MySQL). The class must + // extend AphrontMySQLDatabaseConnectionBase. + 'mysql.implementation' => 'AphrontMySQLDatabaseConnection', + // -- Email ----------------------------------------------------------------- // diff --git a/scripts/sql/upgrade_schema.php b/scripts/sql/upgrade_schema.php index 8426e8dfc1..d486d5a7c0 100755 --- a/scripts/sql/upgrade_schema.php +++ b/scripts/sql/upgrade_schema.php @@ -83,12 +83,15 @@ if ($uri->getPort()) { $conn_bare_hostname = $conn_host; } -$conn = new AphrontMySQLDatabaseConnection( +$conn = PhabricatorEnv::newObjectFromConfig( + 'mysql.implementation', array( - 'user' => $conn_user, - 'pass' => $conn_pass, - 'host' => $conn_host, - 'database' => null, + array( + 'user' => $conn_user, + 'pass' => $conn_pass, + 'host' => $conn_host, + 'database' => null, + ), )); try { diff --git a/src/aphront/console/plugin/services/DarkConsoleServicesPlugin.php b/src/aphront/console/plugin/services/DarkConsoleServicesPlugin.php index 4170562081..6bcc868940 100644 --- a/src/aphront/console/plugin/services/DarkConsoleServicesPlugin.php +++ b/src/aphront/console/plugin/services/DarkConsoleServicesPlugin.php @@ -55,7 +55,9 @@ final class DarkConsoleServicesPlugin extends DarkConsolePlugin { // For each SELECT query, go issue an EXPLAIN on it so we can flag stuff // causing table scans, etc. if (preg_match('/^\s*SELECT\b/i', $entry['query'])) { - $conn = new AphrontMySQLDatabaseConnection($entry['config']); + $conn = PhabricatorEnv::newObjectFromConfig( + 'mysql.implementation', + array($entry['config'])); try { $explain = queryfx_all( $conn, diff --git a/src/aphront/console/plugin/services/__init__.php b/src/aphront/console/plugin/services/__init__.php index 25f0cd604b..de7a6e3a1e 100644 --- a/src/aphront/console/plugin/services/__init__.php +++ b/src/aphront/console/plugin/services/__init__.php @@ -7,7 +7,7 @@ phutil_require_module('phabricator', 'aphront/console/plugin/base'); -phutil_require_module('phabricator', 'storage/connection/mysql/mysql'); +phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phabricator', 'view/control/table'); diff --git a/src/applications/base/storage/lisk/PhabricatorLiskDAO.php b/src/applications/base/storage/lisk/PhabricatorLiskDAO.php index 826a70cfb4..87444bd63d 100644 --- a/src/applications/base/storage/lisk/PhabricatorLiskDAO.php +++ b/src/applications/base/storage/lisk/PhabricatorLiskDAO.php @@ -71,12 +71,15 @@ abstract class PhabricatorLiskDAO extends LiskDAO { PhutilSymbolLoader::loadClass($conf_provider); $conf = newv($conf_provider, array($this, $mode)); - return new AphrontMySQLDatabaseConnection( + return PhabricatorEnv::newObjectFromConfig( + 'mysql.implementation', array( - 'user' => $conf->getUser(), - 'pass' => $conf->getPassword(), - 'host' => $conf->getHost(), - 'database' => $conf->getDatabase(), + array( + 'user' => $conf->getUser(), + 'pass' => $conf->getPassword(), + 'host' => $conf->getHost(), + 'database' => $conf->getDatabase(), + ), )); } diff --git a/src/applications/base/storage/lisk/__init__.php b/src/applications/base/storage/lisk/__init__.php index 961bf49871..a7dd876de9 100644 --- a/src/applications/base/storage/lisk/__init__.php +++ b/src/applications/base/storage/lisk/__init__.php @@ -7,7 +7,6 @@ phutil_require_module('phabricator', 'infrastructure/env'); -phutil_require_module('phabricator', 'storage/connection/mysql/mysql'); phutil_require_module('phabricator', 'storage/lisk/dao'); phutil_require_module('phutil', 'symbols'); diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php index 8dd48c779c..4812b22c34 100644 --- a/src/infrastructure/env/PhabricatorEnv.php +++ b/src/infrastructure/env/PhabricatorEnv.php @@ -55,6 +55,7 @@ final class PhabricatorEnv { 'AphrontApplicationConfiguration', 'controller.oauth-registration' => 'PhabricatorOAuthRegistrationController', + 'mysql.implementation' => 'AphrontMySQLDatabaseConnectionBase', 'differential.attach-task-class' => 'DifferentialTasksAttacher', ); } diff --git a/src/infrastructure/setup/PhabricatorSetup.php b/src/infrastructure/setup/PhabricatorSetup.php index 7a841228e5..024e395092 100644 --- a/src/infrastructure/setup/PhabricatorSetup.php +++ b/src/infrastructure/setup/PhabricatorSetup.php @@ -473,12 +473,15 @@ final class PhabricatorSetup { ini_set('mysql.connect_timeout', 2); - $conn_raw = new AphrontMySQLDatabaseConnection( + $conn_raw = PhabricatorEnv::newObjectFromConfig( + 'mysql.implementation', array( - 'user' => $conn_user, - 'pass' => $conn_pass, - 'host' => $conn_host, - 'database' => null, + array( + 'user' => $conn_user, + 'pass' => $conn_pass, + 'host' => $conn_host, + 'database' => null, + ), )); try { diff --git a/src/infrastructure/setup/__init__.php b/src/infrastructure/setup/__init__.php index b77bda138c..56b5f72d2e 100644 --- a/src/infrastructure/setup/__init__.php +++ b/src/infrastructure/setup/__init__.php @@ -9,7 +9,6 @@ phutil_require_module('phabricator', 'applications/base/storage/configuration'); phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/setup/sql'); -phutil_require_module('phabricator', 'storage/connection/mysql/mysql'); phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phutil', 'filesystem'); diff --git a/webroot/index.php b/webroot/index.php index 49aa7ab4b6..7c8153e7b8 100644 --- a/webroot/index.php +++ b/webroot/index.php @@ -46,11 +46,6 @@ if (!$env) { "is one of 'development', 'production', or a custom environment."); } -if (!function_exists('mysql_connect')) { - phabricator_fatal_config_error( - "The PHP MySQL extension is not installed. This extension is required."); -} - if (!isset($_REQUEST['__path__'])) { phabricator_fatal_config_error( "__path__ is not set. Your rewrite rules are not configured correctly.");