mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 08:12:40 +01:00
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
This commit is contained in:
parent
34ca4a9ba7
commit
d4c5761f41
10 changed files with 34 additions and 24 deletions
|
@ -120,6 +120,11 @@ return array(
|
||||||
// The number of times to try reconnecting to the MySQL database
|
// The number of times to try reconnecting to the MySQL database
|
||||||
'mysql.connection-retries' => 3,
|
'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 ----------------------------------------------------------------- //
|
// -- Email ----------------------------------------------------------------- //
|
||||||
|
|
||||||
|
|
|
@ -83,12 +83,15 @@ if ($uri->getPort()) {
|
||||||
$conn_bare_hostname = $conn_host;
|
$conn_bare_hostname = $conn_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn = new AphrontMySQLDatabaseConnection(
|
$conn = PhabricatorEnv::newObjectFromConfig(
|
||||||
|
'mysql.implementation',
|
||||||
array(
|
array(
|
||||||
'user' => $conn_user,
|
array(
|
||||||
'pass' => $conn_pass,
|
'user' => $conn_user,
|
||||||
'host' => $conn_host,
|
'pass' => $conn_pass,
|
||||||
'database' => null,
|
'host' => $conn_host,
|
||||||
|
'database' => null,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -55,7 +55,9 @@ final class DarkConsoleServicesPlugin extends DarkConsolePlugin {
|
||||||
// For each SELECT query, go issue an EXPLAIN on it so we can flag stuff
|
// For each SELECT query, go issue an EXPLAIN on it so we can flag stuff
|
||||||
// causing table scans, etc.
|
// causing table scans, etc.
|
||||||
if (preg_match('/^\s*SELECT\b/i', $entry['query'])) {
|
if (preg_match('/^\s*SELECT\b/i', $entry['query'])) {
|
||||||
$conn = new AphrontMySQLDatabaseConnection($entry['config']);
|
$conn = PhabricatorEnv::newObjectFromConfig(
|
||||||
|
'mysql.implementation',
|
||||||
|
array($entry['config']));
|
||||||
try {
|
try {
|
||||||
$explain = queryfx_all(
|
$explain = queryfx_all(
|
||||||
$conn,
|
$conn,
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'aphront/console/plugin/base');
|
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', 'storage/queryfx');
|
||||||
phutil_require_module('phabricator', 'view/control/table');
|
phutil_require_module('phabricator', 'view/control/table');
|
||||||
|
|
||||||
|
|
|
@ -71,12 +71,15 @@ abstract class PhabricatorLiskDAO extends LiskDAO {
|
||||||
PhutilSymbolLoader::loadClass($conf_provider);
|
PhutilSymbolLoader::loadClass($conf_provider);
|
||||||
$conf = newv($conf_provider, array($this, $mode));
|
$conf = newv($conf_provider, array($this, $mode));
|
||||||
|
|
||||||
return new AphrontMySQLDatabaseConnection(
|
return PhabricatorEnv::newObjectFromConfig(
|
||||||
|
'mysql.implementation',
|
||||||
array(
|
array(
|
||||||
'user' => $conf->getUser(),
|
array(
|
||||||
'pass' => $conf->getPassword(),
|
'user' => $conf->getUser(),
|
||||||
'host' => $conf->getHost(),
|
'pass' => $conf->getPassword(),
|
||||||
'database' => $conf->getDatabase(),
|
'host' => $conf->getHost(),
|
||||||
|
'database' => $conf->getDatabase(),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'infrastructure/env');
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
phutil_require_module('phabricator', 'storage/connection/mysql/mysql');
|
|
||||||
phutil_require_module('phabricator', 'storage/lisk/dao');
|
phutil_require_module('phabricator', 'storage/lisk/dao');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'symbols');
|
phutil_require_module('phutil', 'symbols');
|
||||||
|
|
1
src/infrastructure/env/PhabricatorEnv.php
vendored
1
src/infrastructure/env/PhabricatorEnv.php
vendored
|
@ -55,6 +55,7 @@ final class PhabricatorEnv {
|
||||||
'AphrontApplicationConfiguration',
|
'AphrontApplicationConfiguration',
|
||||||
'controller.oauth-registration' =>
|
'controller.oauth-registration' =>
|
||||||
'PhabricatorOAuthRegistrationController',
|
'PhabricatorOAuthRegistrationController',
|
||||||
|
'mysql.implementation' => 'AphrontMySQLDatabaseConnectionBase',
|
||||||
'differential.attach-task-class' => 'DifferentialTasksAttacher',
|
'differential.attach-task-class' => 'DifferentialTasksAttacher',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -473,12 +473,15 @@ final class PhabricatorSetup {
|
||||||
|
|
||||||
ini_set('mysql.connect_timeout', 2);
|
ini_set('mysql.connect_timeout', 2);
|
||||||
|
|
||||||
$conn_raw = new AphrontMySQLDatabaseConnection(
|
$conn_raw = PhabricatorEnv::newObjectFromConfig(
|
||||||
|
'mysql.implementation',
|
||||||
array(
|
array(
|
||||||
'user' => $conn_user,
|
array(
|
||||||
'pass' => $conn_pass,
|
'user' => $conn_user,
|
||||||
'host' => $conn_host,
|
'pass' => $conn_pass,
|
||||||
'database' => null,
|
'host' => $conn_host,
|
||||||
|
'database' => null,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
phutil_require_module('phabricator', 'applications/base/storage/configuration');
|
phutil_require_module('phabricator', 'applications/base/storage/configuration');
|
||||||
phutil_require_module('phabricator', 'infrastructure/env');
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
phutil_require_module('phabricator', 'infrastructure/setup/sql');
|
phutil_require_module('phabricator', 'infrastructure/setup/sql');
|
||||||
phutil_require_module('phabricator', 'storage/connection/mysql/mysql');
|
|
||||||
phutil_require_module('phabricator', 'storage/queryfx');
|
phutil_require_module('phabricator', 'storage/queryfx');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'filesystem');
|
phutil_require_module('phutil', 'filesystem');
|
||||||
|
|
|
@ -46,11 +46,6 @@ if (!$env) {
|
||||||
"is one of 'development', 'production', or a custom environment.");
|
"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__'])) {
|
if (!isset($_REQUEST['__path__'])) {
|
||||||
phabricator_fatal_config_error(
|
phabricator_fatal_config_error(
|
||||||
"__path__ is not set. Your rewrite rules are not configured correctly.");
|
"__path__ is not set. Your rewrite rules are not configured correctly.");
|
||||||
|
|
Loading…
Reference in a new issue