MediaWiki REL1_33
|
Public Member Functions | |
__construct (ILoadBalancer $dbLoadBalancer, WANObjectCache $cache, LoggerInterface $logger, $table, $idField, $nameField, callable $normalizationCallback=null, $dbDomain=false, callable $insertCallback=null) | |
acquireId ( $name) | |
Acquire the id of the given name. | |
getId ( $name) | |
Get the id of the given name. | |
getMap () | |
Get the whole table, in no particular order as a map of ids to names. | |
getName ( $id) | |
Get the name of the given id. | |
reloadMap ( $connFlags=0) | |
Reloads the name table from the master database, and purges the WAN cache entry. | |
Private Member Functions | |
getCacheKey () | |
Gets the cache key for names. | |
getDBConnection ( $index, $flags=0) | |
getFieldsToStore ( $name, $id=null) | |
getTableFromCachesOrReplica () | |
loadTable (IDatabase $db) | |
Gets the table from the db. | |
normalizeName ( $name) | |
retryStore (IDatabase $dbw, $name, $id) | |
After the initial insertion got rolled back, this can be used to try the insertion again, and ensure a consistent state of the cache. | |
store ( $name) | |
Stores the given name in the DB, returning the ID when an insert occurs. | |
Private Attributes | |
WANObjectCache | $cache |
int | $cacheTTL |
bool string | $domain = false |
string | $idField |
null callable | $insertCallback = null |
ILoadBalancer | $loadBalancer |
LoggerInterface | $logger |
string | $nameField |
null callable | $normalizationCallback = null |
string | $table |
string[] | $tableCache = null |
Definition at line 36 of file NameTableStore.php.
MediaWiki\Storage\NameTableStore::__construct | ( | ILoadBalancer | $dbLoadBalancer, |
WANObjectCache | $cache, | ||
LoggerInterface | $logger, | ||
$table, | |||
$idField, | |||
$nameField, | |||
callable | $normalizationCallback = null, | ||
$dbDomain = false, | |||
callable | $insertCallback = null ) |
ILoadBalancer | $dbLoadBalancer | A load balancer for acquiring database connections |
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 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 of the cache's default key space. |
LoggerInterface | $logger | |
string | $table | |
string | $idField | |
string | $nameField | |
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. |
bool | string | $dbDomain | Database domain ID. Use false for the local database domain. |
callable | null | $insertCallback | Callback to change insert fields accordingly. This parameter was introduced in 1.32 |
Definition at line 85 of file NameTableStore.php.
References MediaWiki\Storage\NameTableStore\$cache, MediaWiki\Storage\NameTableStore\$idField, MediaWiki\Storage\NameTableStore\$insertCallback, MediaWiki\Storage\NameTableStore\$logger, MediaWiki\Storage\NameTableStore\$nameField, MediaWiki\Storage\NameTableStore\$normalizationCallback, MediaWiki\Storage\NameTableStore\$table, and(), cache, and table.
MediaWiki\Storage\NameTableStore::acquireId | ( | $name | ) |
Acquire the id of the given name.
This creates a row in the table if it doesn't already exist.
string | $name |
NameTableAccessException |
Definition at line 162 of file NameTableStore.php.
References $name, MediaWiki\Storage\NameTableStore\$table, and(), cache, DB_MASTER, MediaWiki\Storage\NameTableStore\getCacheKey(), MediaWiki\Storage\NameTableStore\getDBConnection(), MediaWiki\Storage\NameTableStore\getTableFromCachesOrReplica(), MediaWiki\Storage\NameTableStore\normalizeName(), MediaWiki\Storage\NameTableStore\reloadMap(), and MediaWiki\Storage\NameTableStore\store().
|
private |
Gets the cache key for names.
The cache key is constructed based on the wiki ID passed to the constructor, and allows sharing of name tables cached for a specific database between wikis.
Definition at line 126 of file NameTableStore.php.
Referenced by MediaWiki\Storage\NameTableStore\acquireId(), MediaWiki\Storage\NameTableStore\getName(), MediaWiki\Storage\NameTableStore\getTableFromCachesOrReplica(), and MediaWiki\Storage\NameTableStore\reloadMap().
|
private |
int | $index | A database index, like DB_MASTER or DB_REPLICA |
int | $flags | Database connection flags |
Definition at line 114 of file NameTableStore.php.
Referenced by MediaWiki\Storage\NameTableStore\acquireId(), MediaWiki\Storage\NameTableStore\getName(), MediaWiki\Storage\NameTableStore\getTableFromCachesOrReplica(), MediaWiki\Storage\NameTableStore\reloadMap(), and MediaWiki\Storage\NameTableStore\store().
|
private |
string | $name | |
int | null | $id |
Definition at line 517 of file NameTableStore.php.
References MediaWiki\Storage\NameTableStore\$idField, $name, MediaWiki\Storage\NameTableStore\$nameField, and and().
Referenced by MediaWiki\Storage\NameTableStore\retryStore(), and MediaWiki\Storage\NameTableStore\store().
MediaWiki\Storage\NameTableStore::getId | ( | $name | ) |
Get the id of the given name.
If the name doesn't exist this will throw. This should be used in cases where we believe the name already exists or want to check for existence.
string | $name |
NameTableAccessException | The name does not exist |
Definition at line 255 of file NameTableStore.php.
References MediaWiki\Storage\NameTableStore\$table, and(), MediaWiki\Storage\NameTableStore\getTableFromCachesOrReplica(), MediaWiki\Storage\NameTableAccessException\newFromDetails(), MediaWiki\Storage\NameTableStore\normalizeName(), and table.
MediaWiki\Storage\NameTableStore::getMap | ( | ) |
Get the whole table, in no particular order as a map of ids to names.
This method could be subject to DB or cache lag.
Definition at line 340 of file NameTableStore.php.
References MediaWiki\Storage\NameTableStore\getTableFromCachesOrReplica().
MediaWiki\Storage\NameTableStore::getName | ( | $id | ) |
Get the name of the given id.
If the id doesn't exist this will throw. This should be used in cases where we believe the id already exists.
Note: Calls to this method will result in a master select for non existing IDs.
int | $id |
NameTableAccessException | The id does not exist |
Definition at line 280 of file NameTableStore.php.
References $fname, $source, MediaWiki\Storage\NameTableStore\$table, and(), cache, DB_MASTER, DB_REPLICA, MediaWiki\Storage\NameTableStore\getCacheKey(), MediaWiki\Storage\NameTableStore\getDBConnection(), MediaWiki\Storage\NameTableStore\getTableFromCachesOrReplica(), MediaWiki\Storage\NameTableStore\loadTable(), MediaWiki\Storage\NameTableAccessException\newFromDetails(), and table.
|
private |
Definition at line 347 of file NameTableStore.php.
References $dbr, MediaWiki\Storage\NameTableStore\$table, MediaWiki\Storage\NameTableStore\$tableCache, cache, DB_REPLICA, MediaWiki\Storage\NameTableStore\getCacheKey(), MediaWiki\Storage\NameTableStore\getDBConnection(), and MediaWiki\Storage\NameTableStore\loadTable().
Referenced by MediaWiki\Storage\NameTableStore\acquireId(), MediaWiki\Storage\NameTableStore\getId(), MediaWiki\Storage\NameTableStore\getMap(), and MediaWiki\Storage\NameTableStore\getName().
|
private |
Gets the table from the db.
IDatabase | $db |
Definition at line 374 of file NameTableStore.php.
References and(), Wikimedia\Rdbms\IDatabase\select(), and table.
Referenced by MediaWiki\Storage\NameTableStore\getName(), MediaWiki\Storage\NameTableStore\getTableFromCachesOrReplica(), and MediaWiki\Storage\NameTableStore\reloadMap().
|
private |
string | $name |
Definition at line 138 of file NameTableStore.php.
Referenced by MediaWiki\Storage\NameTableStore\acquireId(), and MediaWiki\Storage\NameTableStore\getId().
MediaWiki\Storage\NameTableStore::reloadMap | ( | $connFlags = 0 | ) |
Reloads the name table from the master database, and purges the WAN cache entry.
int | $connFlags | ILoadBalancer::CONN_XXX flags. Optional. |
Definition at line 229 of file NameTableStore.php.
References MediaWiki\Storage\NameTableStore\$tableCache, cache, DB_MASTER, MediaWiki\Storage\NameTableStore\getCacheKey(), MediaWiki\Storage\NameTableStore\getDBConnection(), and MediaWiki\Storage\NameTableStore\loadTable().
Referenced by MediaWiki\Storage\NameTableStore\acquireId(), and MediaWiki\Storage\NameTableStore\retryStore().
|
private |
After the initial insertion got rolled back, this can be used to try the insertion again, and ensure a consistent state of the cache.
IDatabase | $dbw | |
string | $name | |
int | $id |
Definition at line 454 of file NameTableStore.php.
References $fname, Wikimedia\Rdbms\IDatabase\doAtomicSection(), MediaWiki\Storage\NameTableStore\getFieldsToStore(), Wikimedia\Rdbms\IDatabase\insert(), Wikimedia\Rdbms\IDatabase\onAtomicSectionCancel(), MediaWiki\Storage\NameTableStore\reloadMap(), and table.
Referenced by MediaWiki\Storage\NameTableStore\store().
|
private |
Stores the given name in the DB, returning the ID when an insert occurs.
string | $name |
Definition at line 400 of file NameTableStore.php.
References $fname, DB_MASTER, MediaWiki\Storage\NameTableStore\getDBConnection(), MediaWiki\Storage\NameTableStore\getFieldsToStore(), MediaWiki\Storage\NameTableStore\retryStore(), and table.
Referenced by MediaWiki\Storage\NameTableStore\acquireId().
|
private |
Definition at line 42 of file NameTableStore.php.
Referenced by MediaWiki\Storage\NameTableStore\__construct().
|
private |
Definition at line 54 of file NameTableStore.php.
|
private |
Definition at line 51 of file NameTableStore.php.
|
private |
Definition at line 59 of file NameTableStore.php.
Referenced by MediaWiki\Storage\NameTableStore\__construct(), and MediaWiki\Storage\NameTableStore\getFieldsToStore().
Definition at line 65 of file NameTableStore.php.
Referenced by MediaWiki\Storage\NameTableStore\__construct().
|
private |
Definition at line 39 of file NameTableStore.php.
|
private |
Definition at line 45 of file NameTableStore.php.
Referenced by MediaWiki\Storage\NameTableStore\__construct().
|
private |
Definition at line 61 of file NameTableStore.php.
Referenced by MediaWiki\Storage\NameTableStore\__construct(), and MediaWiki\Storage\NameTableStore\getFieldsToStore().
Definition at line 63 of file NameTableStore.php.
Referenced by MediaWiki\Storage\NameTableStore\__construct().
|
private |
Definition at line 57 of file NameTableStore.php.
Referenced by MediaWiki\Storage\NameTableStore\__construct(), MediaWiki\Storage\NameTableStore\acquireId(), MediaWiki\Storage\NameTableStore\getId(), MediaWiki\Storage\NameTableStore\getName(), and MediaWiki\Storage\NameTableStore\getTableFromCachesOrReplica().
|
private |
Definition at line 48 of file NameTableStore.php.
Referenced by MediaWiki\Storage\NameTableStore\getTableFromCachesOrReplica(), and MediaWiki\Storage\NameTableStore\reloadMap().