X-Git-Url: https://git.cyclocoop.org/admin/?a=blobdiff_plain;f=includes%2FStorage%2FNameTableStore.php;h=5ef03042dc9a96125847f809f1ab63f9263a3220;hb=9bd93469a7b4eee243069c7a4da4cb780ac6716c;hp=3016e992e75d4b54b9f904fe9178a4064a3942fb;hpb=57f118c33689845d647c42e40bf4afda48610978;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Storage/NameTableStore.php b/includes/Storage/NameTableStore.php index 3016e992e7..5ef03042dc 100644 --- a/includes/Storage/NameTableStore.php +++ b/includes/Storage/NameTableStore.php @@ -47,7 +47,7 @@ class NameTableStore { private $tableCache = null; /** @var bool|string */ - private $wikiId = false; + private $domain = false; /** @var int */ private $cacheTTL; @@ -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 @@ -77,7 +77,7 @@ class NameTableStore { * @param string $nameField * @param callable|null $normalizationCallback Normalization to be applied to names before being * saved or queried. This should be a callback that accepts and returns a single string. - * @param bool|string $wikiId The ID of the target wiki database. Use false for the local wiki. + * @param bool|string $dbDomain Database domain ID. Use false for the local database domain. * @param callable|null $insertCallback Callback to change insert fields accordingly. * This parameter was introduced in 1.32 */ @@ -89,7 +89,7 @@ class NameTableStore { $idField, $nameField, callable $normalizationCallback = null, - $wikiId = false, + $dbDomain = false, callable $insertCallback = null ) { $this->loadBalancer = $dbLoadBalancer; @@ -99,7 +99,7 @@ class NameTableStore { $this->idField = $idField; $this->nameField = $nameField; $this->normalizationCallback = $normalizationCallback; - $this->wikiId = $wikiId; + $this->domain = $dbDomain; $this->cacheTTL = IExpiringStore::TTL_MONTH; $this->insertCallback = $insertCallback; } @@ -111,7 +111,7 @@ class NameTableStore { * @return IDatabase */ private function getDBConnection( $index, $flags = 0 ) { - return $this->loadBalancer->getConnection( $index, [], $this->wikiId, $flags ); + return $this->loadBalancer->getConnection( $index, [], $this->domain, $flags ); } /** @@ -126,7 +126,7 @@ class NameTableStore { return $this->cache->makeGlobalKey( 'NameTableSqlStore', $this->table, - $this->loadBalancer->resolveDomainID( $this->wikiId ) + $this->loadBalancer->resolveDomainID( $this->domain ) ); } @@ -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 *