Skip to content

Commit d4c5761

Browse files
author
vrana
committedApr 7, 2012
Customizable MySQL implementation
Test Plan: - / - upgrade_schema.php - Setup - Try disabling mysql_connect. Reviewers: epriestley Reviewed By: epriestley CC: aran Differential Revision: https://secure.phabricator.com/D2133
1 parent 34ca4a9 commit d4c5761

File tree

10 files changed

+34
-24
lines changed

10 files changed

+34
-24
lines changed
 

‎conf/default.conf.php

+5
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@
120120
// The number of times to try reconnecting to the MySQL database
121121
'mysql.connection-retries' => 3,
122122

123+
// Phabricator supports PHP extensions MySQL and MySQLi. It is possible to
124+
// implement also other access mechanism (e.g. PDO_MySQL). The class must
125+
// extend AphrontMySQLDatabaseConnectionBase.
126+
'mysql.implementation' => 'AphrontMySQLDatabaseConnection',
127+
123128

124129
// -- Email ----------------------------------------------------------------- //
125130

‎scripts/sql/upgrade_schema.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,15 @@
8383
$conn_bare_hostname = $conn_host;
8484
}
8585

86-
$conn = new AphrontMySQLDatabaseConnection(
86+
$conn = PhabricatorEnv::newObjectFromConfig(
87+
'mysql.implementation',
8788
array(
88-
'user' => $conn_user,
89-
'pass' => $conn_pass,
90-
'host' => $conn_host,
91-
'database' => null,
89+
array(
90+
'user' => $conn_user,
91+
'pass' => $conn_pass,
92+
'host' => $conn_host,
93+
'database' => null,
94+
),
9295
));
9396

9497
try {

‎src/aphront/console/plugin/services/DarkConsoleServicesPlugin.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ public function generateData() {
5555
// For each SELECT query, go issue an EXPLAIN on it so we can flag stuff
5656
// causing table scans, etc.
5757
if (preg_match('/^\s*SELECT\b/i', $entry['query'])) {
58-
$conn = new AphrontMySQLDatabaseConnection($entry['config']);
58+
$conn = PhabricatorEnv::newObjectFromConfig(
59+
'mysql.implementation',
60+
array($entry['config']));
5961
try {
6062
$explain = queryfx_all(
6163
$conn,

‎src/aphront/console/plugin/services/__init__.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
phutil_require_module('phabricator', 'aphront/console/plugin/base');
10-
phutil_require_module('phabricator', 'storage/connection/mysql/mysql');
10+
phutil_require_module('phabricator', 'infrastructure/env');
1111
phutil_require_module('phabricator', 'storage/queryfx');
1212
phutil_require_module('phabricator', 'view/control/table');
1313

‎src/applications/base/storage/lisk/PhabricatorLiskDAO.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,15 @@ public function establishLiveConnection($mode) {
7171
PhutilSymbolLoader::loadClass($conf_provider);
7272
$conf = newv($conf_provider, array($this, $mode));
7373

74-
return new AphrontMySQLDatabaseConnection(
74+
return PhabricatorEnv::newObjectFromConfig(
75+
'mysql.implementation',
7576
array(
76-
'user' => $conf->getUser(),
77-
'pass' => $conf->getPassword(),
78-
'host' => $conf->getHost(),
79-
'database' => $conf->getDatabase(),
77+
array(
78+
'user' => $conf->getUser(),
79+
'pass' => $conf->getPassword(),
80+
'host' => $conf->getHost(),
81+
'database' => $conf->getDatabase(),
82+
),
8083
));
8184
}
8285

‎src/applications/base/storage/lisk/__init__.php

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
phutil_require_module('phabricator', 'infrastructure/env');
10-
phutil_require_module('phabricator', 'storage/connection/mysql/mysql');
1110
phutil_require_module('phabricator', 'storage/lisk/dao');
1211

1312
phutil_require_module('phutil', 'symbols');

‎src/infrastructure/env/PhabricatorEnv.php

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public static function getRequiredClasses() {
5555
'AphrontApplicationConfiguration',
5656
'controller.oauth-registration' =>
5757
'PhabricatorOAuthRegistrationController',
58+
'mysql.implementation' => 'AphrontMySQLDatabaseConnectionBase',
5859
'differential.attach-task-class' => 'DifferentialTasksAttacher',
5960
);
6061
}

‎src/infrastructure/setup/PhabricatorSetup.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -473,12 +473,15 @@ public static function runSetup() {
473473

474474
ini_set('mysql.connect_timeout', 2);
475475

476-
$conn_raw = new AphrontMySQLDatabaseConnection(
476+
$conn_raw = PhabricatorEnv::newObjectFromConfig(
477+
'mysql.implementation',
477478
array(
478-
'user' => $conn_user,
479-
'pass' => $conn_pass,
480-
'host' => $conn_host,
481-
'database' => null,
479+
array(
480+
'user' => $conn_user,
481+
'pass' => $conn_pass,
482+
'host' => $conn_host,
483+
'database' => null,
484+
),
482485
));
483486

484487
try {

‎src/infrastructure/setup/__init__.php

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
phutil_require_module('phabricator', 'applications/base/storage/configuration');
1010
phutil_require_module('phabricator', 'infrastructure/env');
1111
phutil_require_module('phabricator', 'infrastructure/setup/sql');
12-
phutil_require_module('phabricator', 'storage/connection/mysql/mysql');
1312
phutil_require_module('phabricator', 'storage/queryfx');
1413

1514
phutil_require_module('phutil', 'filesystem');

‎webroot/index.php

-5
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@
4646
"is one of 'development', 'production', or a custom environment.");
4747
}
4848

49-
if (!function_exists('mysql_connect')) {
50-
phabricator_fatal_config_error(
51-
"The PHP MySQL extension is not installed. This extension is required.");
52-
}
53-
5449
if (!isset($_REQUEST['__path__'])) {
5550
phabricator_fatal_config_error(
5651
"__path__ is not set. Your rewrite rules are not configured correctly.");

0 commit comments

Comments
 (0)
Failed to load comments.