private $tableCache = null;
/** @var bool|string */
- private $wikiId = false;
+ private $domain = false;
/** @var int */
private $cacheTTL;
/**
* @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
* @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
*/
$idField,
$nameField,
callable $normalizationCallback = null,
- $wikiId = false,
+ $dbDomain = false,
callable $insertCallback = null
) {
$this->loadBalancer = $dbLoadBalancer;
$this->idField = $idField;
$this->nameField = $nameField;
$this->normalizationCallback = $normalizationCallback;
- $this->wikiId = $wikiId;
+ $this->domain = $dbDomain;
$this->cacheTTL = IExpiringStore::TTL_MONTH;
$this->insertCallback = $insertCallback;
}
* @return IDatabase
*/
private function getDBConnection( $index, $flags = 0 ) {
- return $this->loadBalancer->getConnection( $index, [], $this->wikiId, $flags );
+ return $this->loadBalancer->getConnection( $index, [], $this->domain, $flags );
}
/**
return $this->cache->makeGlobalKey(
'NameTableSqlStore',
$this->table,
- $this->loadBalancer->resolveDomainID( $this->wikiId )
+ $this->loadBalancer->resolveDomainID( $this->domain )
);
}
$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;
}
* @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;
}
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
*