LockManagerGroup tweaks
authorAryeh Gregor <ayg@aryeh.name>
Thu, 15 Aug 2019 18:07:36 +0000 (21:07 +0300)
committerAryeh Gregor <ayg@aryeh.name>
Wed, 28 Aug 2019 07:49:37 +0000 (10:49 +0300)
One small change that was supposed to be in 5a6c18a0863 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

includes/DefaultSettings.php
includes/filebackend/lockmanager/LockManagerGroup.php
includes/filebackend/lockmanager/LockManagerGroupFactory.php
tests/phpunit/includes/filebackend/lockmanager/LockManagerGroupIntegrationTest.php

index 7e13fc2..6c5c3d2 100644 (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 = [];
 
index 7da3753..9b43164 100644 (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 );
                }
 
index 54bbc3d..9c8d4bb 100644 (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;
                }
 
index 0615e95..45ad180 100644 (file)
@@ -41,7 +41,7 @@ class LockManagerGroupIntegrationTest extends MediaWikiIntegrationTestCase {
                LockManagerGroup::destroySingletons();
 
                $this->assertSame(
-                       null,
+                       WikiMap::getCurrentWikiDbDomain()->getId(),
                        LockManagerGroup::singleton( null )->config( 'a' )['domain']
                );
        }