LockManagerGroup tweaks

One small change that was supposed to be in 5a6c18a086 but didn't make
it into the patch version that got merged, and removal of some long-dead
code.

phan objected to the use of new $class without being explicitly
reassured that $class is, in fact, a string. I don't know why.

Change-Id: Ifa00c59ab4464109414f21db37e3a6db21decdf3
This commit is contained in:
Aryeh Gregor 2019-08-15 21:07:36 +03:00
parent c1e9d63dfd
commit 37022e2e89
4 changed files with 5 additions and 24 deletions

View file

@ -788,10 +788,6 @@ $wgFileBackends = [];
* See LockManager::__construct() for more details.
* Additional parameters are specific to the lock manager class used.
* These settings should be global to all wikis.
*
* When using DBLockManager, the 'dbsByBucket' map can reference 'localDBMaster' as
* a peer database in each bucket. This will result in an extra connection to the domain
* that the LockManager services, which must also be a valid wiki ID.
*/
$wgLockManagers = [];

View file

@ -104,25 +104,10 @@ class LockManagerGroup {
// Lazy-load the actual lock manager instance
if ( !isset( $this->managers[$name]['instance'] ) ) {
$class = $this->managers[$name]['class'];
'@phan-var string $class';
$config = $this->managers[$name]['config'];
if ( $class === DBLockManager::class ) {
$lb = $this->lbFactory->getMainLB( $config['domain'] );
$config['dbServers']['localDBMaster'] = $lb->getLazyConnectionRef(
DB_MASTER,
[],
$config['domain'],
$lb::CONN_TRX_AUTOCOMMIT
);
$config['srvCache'] = ObjectCache::getLocalServerInstance( 'hash' );
}
$config['logger'] = LoggerFactory::getInstance( 'LockManager' );
// XXX Looks like phan is right, we are trying to instantiate an abstract class and it
// throws. Did this ever work? Presumably we need to detect the right subclass? Or
// should we just get rid of this? It looks like it never worked since it was first
// introduced by 0cf832a3394 in 2016, so if no one's complained until now, clearly it
// can't be very useful?
// @phan-suppress-next-line PhanTypeInstantiateAbstract
$this->managers[$name]['instance'] = new $class( $config );
}

View file

@ -35,12 +35,12 @@ class LockManagerGroupFactory {
}
/**
* @param string|bool $domain Domain (usually wiki ID). false for the default (normally the
* current wiki's domain).
* @param string|null|false $domain Domain (usually wiki ID). false for the default (normally
* the current wiki's domain).
* @return LockManagerGroup
*/
public function getLockManagerGroup( $domain = false ) : LockManagerGroup {
if ( $domain === false ) {
if ( $domain === false || $domain === null ) {
$domain = $this->defaultDomain;
}

View file

@ -41,7 +41,7 @@ class LockManagerGroupIntegrationTest extends MediaWikiIntegrationTestCase {
LockManagerGroup::destroySingletons();
$this->assertSame(
null,
WikiMap::getCurrentWikiDbDomain()->getId(),
LockManagerGroup::singleton( null )->config( 'a' )['domain']
);
}