Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/311170
Change subject: Cleanup setDomainPrefix() methods to handle existing LBs/DBs ...................................................................... Cleanup setDomainPrefix() methods to handle existing LBs/DBs Change-Id: Ifa1efc3f7097fb1b8ab7d49fa18f10d76cd1641e --- M includes/db/CloneDatabase.php M includes/libs/rdbms/lbfactory/LBFactory.php M includes/libs/rdbms/loadbalancer/LoadBalancer.php 3 files changed, 13 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/70/311170/1 diff --git a/includes/db/CloneDatabase.php b/includes/db/CloneDatabase.php index ee82bdf..2af742e 100644 --- a/includes/db/CloneDatabase.php +++ b/includes/db/CloneDatabase.php @@ -132,12 +132,6 @@ $lbFactory = wfGetLBFactory(); $lbFactory->setDomainPrefix( $prefix ); - $lbFactory->forEachLB( function( LoadBalancer $lb ) use ( $prefix ) { - $lb->setDomainPrefix( $prefix ); - $lb->forEachOpenConnection( function ( IDatabase $db ) use ( $prefix ) { - $db->tablePrefix( $prefix ); - } ); - } ); $wgDBprefix = $prefix; } } diff --git a/includes/libs/rdbms/lbfactory/LBFactory.php b/includes/libs/rdbms/lbfactory/LBFactory.php index b6f3317..e011ff0 100644 --- a/includes/libs/rdbms/lbfactory/LBFactory.php +++ b/includes/libs/rdbms/lbfactory/LBFactory.php @@ -633,15 +633,18 @@ } /** - * Define a new local domain (for testing) + * Set a new table prefix for the existing local domain ID for testing * - * Caller should make sure no local connection are open to the old local domain - * - * @param string $domain + * @param string $prefix * @since 1.28 */ - public function setDomainPrefix( $domain ) { - $this->localDomain = $domain; + public function setDomainPrefix( $prefix ) { + list( $dbName, ) = explode( '-', $this->localDomain, 2 ); + $this->localDomain = "{$dbName}-{$prefix}"; + + $this->forEachLB( function( LoadBalancer $lb ) use ( $prefix ) { + $lb->setDomainPrefix( $prefix ); + } ); } /** diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index db69de1..8943ae6 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -1607,7 +1607,10 @@ */ public function setDomainPrefix( $prefix ) { list( $dbName, ) = explode( '-', $this->localDomain, 2 ); - $this->localDomain = "{$dbName}-{$prefix}"; + + $this->forEachOpenConnection( function ( IDatabase $db ) use ( $prefix ) { + $db->tablePrefix( $prefix ); + } ); } } -- To view, visit https://gerrit.wikimedia.org/r/311170 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifa1efc3f7097fb1b8ab7d49fa18f10d76cd1641e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits