@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.

Remove "mysql.configuration-provider" configuration option

Summary:
Ref T11044. This was old Facebook cruft for reading configuration from SMC (and maybe doing some other questionable things). See D183.

(See also D175 for discussion of this from 2011.)

In modern Phabricator, you can subclass `SiteConfig` to provide dynamic configuration, and we do so in the Phacility cluster. This lets you change any config, and change in response to requests (e.g., for instancing) and is generally more powerful than this mechanism was.

This configuration provider theoretically let you roll your own replication or partitioning, but in practice I believe no one ever did, and no one ever could have anyway without more support in the upstream (for migrations, read-after-write, etc).

Test Plan:
- Grepped for removed option.
- Browsed around with clustering off.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11044

Differential Revision: https://secure.phabricator.com/D16911

+19 -117
-6
src/__phutil_library_map__.php
··· 345 345 'DarkConsoleStartupPlugin' => 'applications/console/plugin/DarkConsoleStartupPlugin.php', 346 346 'DarkConsoleXHProfPlugin' => 'applications/console/plugin/DarkConsoleXHProfPlugin.php', 347 347 'DarkConsoleXHProfPluginAPI' => 'applications/console/plugin/xhprof/DarkConsoleXHProfPluginAPI.php', 348 - 'DatabaseConfigurationProvider' => 'infrastructure/storage/configuration/DatabaseConfigurationProvider.php', 349 - 'DefaultDatabaseConfigurationProvider' => 'infrastructure/storage/configuration/DefaultDatabaseConfigurationProvider.php', 350 348 'DifferentialAction' => 'applications/differential/constants/DifferentialAction.php', 351 349 'DifferentialActionEmailCommand' => 'applications/differential/command/DifferentialActionEmailCommand.php', 352 350 'DifferentialAddCommentView' => 'applications/differential/view/DifferentialAddCommentView.php', ··· 4949 4947 'DarkConsoleStartupPlugin' => 'DarkConsolePlugin', 4950 4948 'DarkConsoleXHProfPlugin' => 'DarkConsolePlugin', 4951 4949 'DarkConsoleXHProfPluginAPI' => 'Phobject', 4952 - 'DefaultDatabaseConfigurationProvider' => array( 4953 - 'Phobject', 4954 - 'DatabaseConfigurationProvider', 4955 - ), 4956 4950 'DifferentialAction' => 'Phobject', 4957 4951 'DifferentialActionEmailCommand' => 'MetaMTAEmailTransactionCommand', 4958 4952 'DifferentialAddCommentView' => 'AphrontView',
+4
src/applications/config/check/PhabricatorExtraConfigSetupCheck.php
··· 344 344 'mysql.implementation' => pht( 345 345 'Phabricator now automatically selects the best available '. 346 346 'MySQL implementation.'), 347 + 348 + 'mysql.configuration-provider' => pht( 349 + 'Phabricator now has application-level management of partitioning '. 350 + 'and replicas.'), 347 351 ); 348 352 349 353 return $ancient_config;
-13
src/applications/config/option/PhabricatorMySQLConfigOptions.php
··· 35 35 ->setHidden(true) 36 36 ->setDescription( 37 37 pht('MySQL password to use when connecting to the database.')), 38 - $this->newOption( 39 - 'mysql.configuration-provider', 40 - 'class', 41 - 'DefaultDatabaseConfigurationProvider') 42 - ->setLocked(true) 43 - ->setBaseClass('DatabaseConfigurationProvider') 44 - ->setSummary( 45 - pht('Configure database configuration class.')) 46 - ->setDescription( 47 - pht( 48 - 'Phabricator chooses which database to connect to through a '. 49 - 'swappable configuration provider. You almost certainly do not '. 50 - 'need to change this.')), 51 38 $this->newOption('storage.default-namespace', 'string', 'phabricator') 52 39 ->setLocked(true) 53 40 ->setSummary(
+11 -8
src/infrastructure/cluster/PhabricatorDatabaseRef.php
··· 569 569 } 570 570 571 571 public static function newIndividualRef() { 572 - $conf = PhabricatorEnv::newObjectFromConfig( 573 - 'mysql.configuration-provider', 574 - array(null, 'w', null)); 572 + $default_user = PhabricatorEnv::getEnvConfig('mysql.user'); 573 + $default_pass = new PhutilOpaqueEnvelope( 574 + PhabricatorEnv::getEnvConfig('mysql.pass')); 575 + $default_host = PhabricatorEnv::getEnvConfig('mysql.host'); 576 + $default_port = PhabricatorEnv::getEnvConfig('mysql.port'); 575 577 576 578 return id(new self()) 577 - ->setHost($conf->getHost()) 578 - ->setPort($conf->getPort()) 579 - ->setUser($conf->getUser()) 580 - ->setPass($conf->getPassword()) 579 + ->setUser($default_user) 580 + ->setPass($default_pass) 581 + ->setHost($default_host) 582 + ->setPort($default_port) 581 583 ->setIsIndividual(true) 582 - ->setIsMaster(true); 584 + ->setIsMaster(true) 585 + ->setIsDefaultPartition(true); 583 586 } 584 587 585 588 public static function getAllReplicaDatabaseRefs() {
-16
src/infrastructure/storage/configuration/DatabaseConfigurationProvider.php
··· 1 - <?php 2 - 3 - interface DatabaseConfigurationProvider { 4 - 5 - public function __construct( 6 - LiskDAO $dao = null, 7 - $mode = 'r', 8 - $namespace = 'phabricator'); 9 - 10 - public function getUser(); 11 - public function getPassword(); 12 - public function getHost(); 13 - public function getPort(); 14 - public function getDatabase(); 15 - 16 - }
-48
src/infrastructure/storage/configuration/DefaultDatabaseConfigurationProvider.php
··· 1 - <?php 2 - 3 - final class DefaultDatabaseConfigurationProvider 4 - extends Phobject 5 - implements DatabaseConfigurationProvider { 6 - 7 - private $dao; 8 - private $mode; 9 - private $namespace; 10 - 11 - public function __construct( 12 - LiskDAO $dao = null, 13 - $mode = 'r', 14 - $namespace = 'phabricator') { 15 - 16 - $this->dao = $dao; 17 - $this->mode = $mode; 18 - $this->namespace = $namespace; 19 - } 20 - 21 - public function getUser() { 22 - return PhabricatorEnv::getEnvConfig('mysql.user'); 23 - } 24 - 25 - public function getPassword() { 26 - return new PhutilOpaqueEnvelope(PhabricatorEnv::getEnvConfig('mysql.pass')); 27 - } 28 - 29 - public function getHost() { 30 - return PhabricatorEnv::getEnvConfig('mysql.host'); 31 - } 32 - 33 - public function getPort() { 34 - return PhabricatorEnv::getEnvConfig('mysql.port'); 35 - } 36 - 37 - public function getDatabase() { 38 - if (!$this->getDao()) { 39 - return null; 40 - } 41 - return $this->namespace.'_'.$this->getDao()->getApplicationName(); 42 - } 43 - 44 - protected function getDao() { 45 - return $this->dao; 46 - } 47 - 48 - }
+4 -26
src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
··· 60 60 $this->raiseImproperWrite($database); 61 61 } 62 62 63 - $is_cluster = (bool)PhabricatorEnv::getEnvConfig('cluster.databases'); 64 - if ($is_cluster) { 65 - $connection = $this->newClusterConnection( 66 - $this->getApplicationName(), 67 - $database, 68 - $mode); 69 - } else { 70 - $connection = $this->newBasicConnection($database, $mode, $namespace); 71 - } 63 + $connection = $this->newClusterConnection( 64 + $this->getApplicationName(), 65 + $database, 66 + $mode); 72 67 73 68 // TODO: This should be testing if the mode is "r", but that would probably 74 69 // break a lot of things. Perform a more narrow test for readonly mode ··· 94 89 } 95 90 96 91 return $connection; 97 - } 98 - 99 - private function newBasicConnection($database, $mode, $namespace) { 100 - $conf = PhabricatorEnv::newObjectFromConfig( 101 - 'mysql.configuration-provider', 102 - array($this, $mode, $namespace)); 103 - 104 - return PhabricatorDatabaseRef::newRawConnection( 105 - array( 106 - 'user' => $conf->getUser(), 107 - 'pass' => $conf->getPassword(), 108 - 'host' => $conf->getHost(), 109 - 'port' => $conf->getPort(), 110 - 'database' => $database, 111 - 'retries' => 3, 112 - 'timeout' => 10, 113 - )); 114 92 } 115 93 116 94 private function newClusterConnection($application, $database, $mode) {