Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/schema/PhabricatorConfigSchemaQuery.php
| <?php | <?php | ||||
| final class PhabricatorConfigSchemaQuery extends Phobject { | final class PhabricatorConfigSchemaQuery extends Phobject { | ||||
| private $refs; | |||||
| private $apis; | |||||
| public function setRefs(array $refs) { | |||||
| $this->refs = $refs; | |||||
| return $this; | |||||
| } | |||||
| public function getRefs() { | |||||
| if (!$this->refs) { | |||||
| return PhabricatorDatabaseRef::getMasterDatabaseRefs(); | |||||
| } | |||||
| return $this->refs; | |||||
| } | |||||
| public function setAPIs(array $apis) { | |||||
| $map = array(); | |||||
| foreach ($apis as $api) { | |||||
| $map[$api->getRef()->getRefKey()] = $api; | |||||
| } | |||||
| $this->apis = $map; | |||||
| return $this; | |||||
| } | |||||
| private function getDatabaseNames(PhabricatorDatabaseRef $ref) { | private function getDatabaseNames(PhabricatorDatabaseRef $ref) { | ||||
| $api = $this->getAPI($ref); | $api = $this->getAPI($ref); | ||||
| $patches = PhabricatorSQLPatchList::buildAllPatches(); | $patches = PhabricatorSQLPatchList::buildAllPatches(); | ||||
| return $api->getDatabaseList( | return $api->getDatabaseList( | ||||
| $patches, | $patches, | ||||
| $only_living = true); | $only_living = true); | ||||
| } | } | ||||
| private function getAPI(PhabricatorDatabaseRef $ref) { | private function getAPI(PhabricatorDatabaseRef $ref) { | ||||
| $key = $ref->getRefKey(); | |||||
| if (isset($this->apis[$key])) { | |||||
| return $this->apis[$key]; | |||||
| } | |||||
| return id(new PhabricatorStorageManagementAPI()) | return id(new PhabricatorStorageManagementAPI()) | ||||
| ->setUser($ref->getUser()) | ->setUser($ref->getUser()) | ||||
| ->setHost($ref->getHost()) | ->setHost($ref->getHost()) | ||||
| ->setPort($ref->getPort()) | ->setPort($ref->getPort()) | ||||
| ->setNamespace(PhabricatorLiskDAO::getDefaultStorageNamespace()) | ->setNamespace(PhabricatorLiskDAO::getDefaultStorageNamespace()) | ||||
| ->setPassword($ref->getPass()); | ->setPassword($ref->getPass()); | ||||
| } | } | ||||
| public function loadActualSchemata() { | public function loadActualSchemata() { | ||||
| $refs = PhabricatorDatabaseRef::getMasterDatabaseRefs(); | $refs = $this->getRefs(); | ||||
| $schemata = array(); | $schemata = array(); | ||||
| foreach ($refs as $ref) { | foreach ($refs as $ref) { | ||||
| $schema = $this->loadActualSchemaForServer($ref); | $schema = $this->loadActualSchemaForServer($ref); | ||||
| $schemata[$schema->getRef()->getRefKey()] = $schema; | $schemata[$schema->getRef()->getRefKey()] = $schema; | ||||
| } | } | ||||
| return $schemata; | return $schemata; | ||||
| ▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | foreach ($invisible_databases as $database_name) { | ||||
| ->setName($database_name) | ->setName($database_name) | ||||
| ->setAccessDenied(true)); | ->setAccessDenied(true)); | ||||
| } | } | ||||
| return $server_schema; | return $server_schema; | ||||
| } | } | ||||
| public function loadExpectedSchemata() { | public function loadExpectedSchemata() { | ||||
| $refs = PhabricatorDatabaseRef::getMasterDatabaseRefs(); | $refs = $this->getRefs(); | ||||
| $schemata = array(); | $schemata = array(); | ||||
| foreach ($refs as $ref) { | foreach ($refs as $ref) { | ||||
| $schema = $this->loadExpectedSchemaForServer($ref); | $schema = $this->loadExpectedSchemaForServer($ref); | ||||
| $schemata[$schema->getRef()->getRefKey()] = $schema; | $schemata[$schema->getRef()->getRefKey()] = $schema; | ||||
| } | } | ||||
| return $schemata; | return $schemata; | ||||
| ▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines | |||||