Merge "maintenance: Script to rename titles for Unicode uppercasing changes"
[lhc/web/wiklou.git] / includes / Storage / NameTableStore.php
index bf88b20..5ef0304 100644 (file)
@@ -66,7 +66,7 @@ class NameTableStore {
        /**
         * @param ILoadBalancer $dbLoadBalancer A load balancer for acquiring database connections
         * @param WANObjectCache $cache A cache manager for caching data. This can be the local
-        *        wiki's default instance even if $wikiId refers to a different wiki, since
+        *        wiki's default instance even if $dbDomain refers to a different wiki, since
         *        makeGlobalKey() is used to constructed a key that allows cached names from
         *        the same database to be re-used between wikis. For example, enwiki and frwiki will
         *        use the same cache keys for names from the wikidatawiki database, regardless
@@ -183,11 +183,10 @@ class NameTableStore {
                                $searchResult = $id;
 
                                // As store returned an ID we know we inserted so delete from WAN cache
-                               $this->purgeWANCache(
-                                       function () {
-                                               $this->cache->delete( $this->getCacheKey() );
-                                       }
-                               );
+                               $dbw = $this->getDBConnection( DB_MASTER );
+                               $dbw->onTransactionPreCommitOrIdle( function () {
+                                       $this->cache->delete( $this->getCacheKey() );
+                               } );
                        }
                        $this->tableCache = $table;
                }
@@ -208,14 +207,11 @@ class NameTableStore {
         * @return string[] The freshly reloaded name map
         */
        public function reloadMap( $connFlags = 0 ) {
-               $this->tableCache = $this->loadTable(
-                       $this->getDBConnection( DB_MASTER, $connFlags )
-               );
-               $this->purgeWANCache(
-                       function () {
-                               $this->cache->reap( $this->getCacheKey(), INF );
-                       }
-               );
+               $dbw = $this->getDBConnection( DB_MASTER, $connFlags );
+               $this->tableCache = $this->loadTable( $dbw );
+               $dbw->onTransactionPreCommitOrIdle( function () {
+                       $this->cache->reap( $this->getCacheKey(), INF );
+               } );
 
                return $this->tableCache;
        }
@@ -342,22 +338,6 @@ class NameTableStore {
                return $table;
        }
 
-       /**
-        * Reap the WANCache entry for this table.
-        *
-        * @param callable $purgeCallback Callback to 'purge' the WAN cache
-        */
-       private function purgeWANCache( $purgeCallback ) {
-               // If the LB has no DB changes don't bother with onTransactionPreCommitOrIdle
-               if ( !$this->loadBalancer->hasOrMadeRecentMasterChanges() ) {
-                       $purgeCallback();
-                       return;
-               }
-
-               $this->getDBConnection( DB_MASTER )
-                       ->onTransactionPreCommitOrIdle( $purgeCallback, __METHOD__ );
-       }
-
        /**
         * Gets the table from the db
         *