Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | /* -( Configuring Storage )------------------------------------------------ */ | ||||
*/ | */ | ||||
protected function establishLiveConnection($mode) { | protected function establishLiveConnection($mode) { | ||||
$namespace = self::getStorageNamespace(); | $namespace = self::getStorageNamespace(); | ||||
$conf = PhabricatorEnv::newObjectFromConfig( | $conf = PhabricatorEnv::newObjectFromConfig( | ||||
'mysql.configuration-provider', | 'mysql.configuration-provider', | ||||
array($this, $mode, $namespace)); | array($this, $mode, $namespace)); | ||||
return PhabricatorEnv::newObjectFromConfig( | $is_readonly = PhabricatorEnv::isReadOnly(); | ||||
if ($is_readonly && ($mode != 'r')) { | |||||
throw new Exception( | |||||
pht( | |||||
'Attempting to establish write-mode connection from a read-only '. | |||||
'page (to database "%s").', | |||||
$conf->getDatabase())); | |||||
} | |||||
$connection = PhabricatorEnv::newObjectFromConfig( | |||||
'mysql.implementation', | 'mysql.implementation', | ||||
array( | array( | ||||
array( | array( | ||||
'user' => $conf->getUser(), | 'user' => $conf->getUser(), | ||||
'pass' => $conf->getPassword(), | 'pass' => $conf->getPassword(), | ||||
'host' => $conf->getHost(), | 'host' => $conf->getHost(), | ||||
'port' => $conf->getPort(), | 'port' => $conf->getPort(), | ||||
'database' => $conf->getDatabase(), | 'database' => $conf->getDatabase(), | ||||
'retries' => 3, | 'retries' => 3, | ||||
), | ), | ||||
)); | )); | ||||
// TODO: This should be testing if the mode is "r", but that would proably | |||||
// break a lot of things. Perform a more narrow test for readonly mode | |||||
// until we have greater certainty that this works correctly most of the | |||||
// time. | |||||
if ($is_readonly) { | |||||
$connection->setReadOnly(true); | |||||
} | |||||
return $connection; | |||||
} | } | ||||
/** | /** | ||||
* @task config | * @task config | ||||
*/ | */ | ||||
public function getTableName() { | public function getTableName() { | ||||
$str = 'phabricator'; | $str = 'phabricator'; | ||||
$len = strlen($str); | $len = strlen($str); | ||||
▲ Show 20 Lines • Show All 165 Lines • Show Last 20 Lines |