@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Hook for database configuration plugin

Summary:
This permits individual deployments to better configure their
database configuration, e.g. to allow more dynamic configuration that reacts
to database moves or master/slave replication.

Test Plan:
Browse

Reviewed By: epriestley
Reviewers: Girish, epriestley
CC: aran, epriestley
Differential Revision: 183

adonohue c2893d86 c59b56b4

+79 -16
-7
conf/default.conf.php
··· 111 111 // The MySQL server to connect to. 112 112 'mysql.host' => 'localhost', 113 113 114 - // READ-ONLY database connection information 115 - // If you have a read-only slave mysql server, then you can fill out the 116 - // below fields. If not, duplicate the above information for the slave. 117 - 'mysql_slave.user' => 'root', 118 - 'mysql_slave.pass' => '', 119 - 'mysql_slave.host' => 'localhost', 120 - 121 114 // -- Email ----------------------------------------------------------------- // 122 115 123 116 // Some Phabricator tools send email notifications, e.g. when Differential
+1
src/__phutil_library_map__.php
··· 107 107 'DarkConsoleServicesPluginAPI' => 'aphront/console/plugin/services/api', 108 108 'DarkConsoleXHProfPlugin' => 'aphront/console/plugin/xhprof', 109 109 'DarkConsoleXHProfPluginAPI' => 'aphront/console/plugin/xhprof/api', 110 + 'DatabaseConfigurationProvider' => 'applications/base/storage/configuration', 110 111 'DifferentialAction' => 'applications/differential/constants/action', 111 112 'DifferentialAddCommentView' => 'applications/differential/view/addcomment', 112 113 'DifferentialAttachController' => 'applications/differential/controller/attach',
+51
src/applications/base/storage/configuration/DatabaseConfigurationProvider.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + class DatabaseConfigurationProvider { 20 + private $dao; 21 + private $mode; 22 + 23 + public function __construct(LiskDAO $dao, $mode) { 24 + $this->dao = $dao; 25 + $this->mode = $mode; 26 + } 27 + 28 + public function getUser() { 29 + return PhabricatorEnv::getEnvConfig('mysql.user'); 30 + } 31 + 32 + public function getPassword() { 33 + return PhabricatorEnv::getEnvConfig('mysql.pass'); 34 + } 35 + 36 + public function getHost() { 37 + return PhabricatorEnv::getEnvConfig('mysql.host'); 38 + } 39 + 40 + public function getDatabase() { 41 + return 'phabricator_'.$this->getDao()->getApplicationName(); 42 + } 43 + 44 + final protected function getDao() { 45 + return $this->dao; 46 + } 47 + 48 + final protected function getMode() { 49 + return $this->mode; 50 + } 51 + }
+12
src/applications/base/storage/configuration/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'infrastructure/env'); 10 + 11 + 12 + phutil_require_source('DatabaseConfigurationProvider.php');
+9 -9
src/applications/base/storage/lisk/PhabricatorLiskDAO.php
··· 20 20 abstract class PhabricatorLiskDAO extends LiskDAO { 21 21 22 22 public function establishConnection($mode) { 23 - $mysql_key = 'mysql'; 24 - if ($mode == 'r') { 25 - $mysql_key = 'mysql_slave'; 26 - } 23 + $conf_provider = PhabricatorEnv::getEnvConfig( 24 + 'mysql.configuration_provider', 'DatabaseConfigurationProvider'); 25 + PhutilSymbolLoader::loadClass($conf_provider); 26 + $conf = newv($conf_provider, array($this, $mode)); 27 + 27 28 return new AphrontMySQLDatabaseConnection( 28 29 array( 29 - 'user' => PhabricatorEnv::getEnvConfig($mysql_key.'.user'), 30 - 'pass' => PhabricatorEnv::getEnvConfig($mysql_key.'.pass'), 31 - 'host' => PhabricatorEnv::getEnvConfig($mysql_key.'.host'), 32 - 'database' => 'phabricator_'.$this->getApplicationName(), 30 + 'user' => $conf->getUser(), 31 + 'pass' => $conf->getPassword(), 32 + 'host' => $conf->getHost(), 33 + 'database' => $conf->getDatabase(), 33 34 )); 34 - 35 35 } 36 36 37 37 public function getTableName() {
+3
src/applications/base/storage/lisk/__init__.php
··· 10 10 phutil_require_module('phabricator', 'storage/connection/mysql'); 11 11 phutil_require_module('phabricator', 'storage/lisk/dao'); 12 12 13 + phutil_require_module('phutil', 'symbols'); 14 + phutil_require_module('phutil', 'utils'); 15 + 13 16 14 17 phutil_require_source('PhabricatorLiskDAO.php');
+3
src/storage/lisk/dao/LiskDAO.php
··· 603 603 throw new Exception("Unknown mode '{$mode}', should be 'r' or 'w'."); 604 604 } 605 605 606 + // TODO There is currently no protection on 'r' queries against writing 607 + // or on 'w' queries against reading 608 + 606 609 if (!isset($this->__connections[$mode])) { 607 610 $this->__connections[$mode] = $this->establishConnection($mode); 608 611 }