96 $this->loadBalancer = $dbLoadBalancer;
104 $this->cacheTTL = IExpiringStore::TTL_MONTH;
115 return $this->loadBalancer->getConnectionRef( $index, [], $this->domain, $flags );
127 return $this->
cache->makeGlobalKey(
130 $this->loadBalancer->resolveDomainID( $this->domain )
139 if ( $this->normalizationCallback ===
null ) {
163 Assert::parameterType(
'string', $name,
'$name' );
168 if ( $searchResult ===
false ) {
169 $id = $this->
store( $name );
170 if ( $id ===
null ) {
175 $connFlags = defined(
'MW_PHPUNIT_TEST' ) ? 0 : ILoadBalancer::CONN_TRX_AUTOCOMMIT;
179 if ( $searchResult ===
false ) {
181 $m =
"No insert possible but master didn't give us a record for " .
182 "'{$name}' in '{$this->table}'";
183 $this->logger->error( $m );
194 $m =
"Got ID $id for '$name' from insert"
195 .
" into '{$this->table}', but ID $id was previously associated with"
196 .
" the name '{$table[$id]}'. Overriding the old value, which presumably"
197 .
" has been removed from the database due to a transaction rollback.";
199 $this->logger->warning( $m );
207 $dbw->onTransactionPreCommitOrIdle(
function () {
211 $this->tableCache =
$table;
230 if ( $connFlags !== 0 && defined(
'MW_PHPUNIT_TEST' ) ) {
237 $this->tableCache = $this->
loadTable( $dbw );
238 $dbw->onTransactionPreCommitOrIdle(
function () {
256 Assert::parameterType(
'string', $name,
'$name' );
262 if ( $searchResult !==
false ) {
281 Assert::parameterType(
'integer', $id,
'$id' );
292 function ( $oldValue, &$ttl, &$setOpts ) use ( $id,
$fname ) {
296 $ttl = WANObjectCache::TTL_UNCACHEABLE;
305 $fname .
' falling back to master select from ' .
306 $this->
table .
' with id ' . $id
310 $cacheSetOpts = Database::getCacheSetOptions( $db );
324 $this->tableCache =
$table;
348 if ( $this->tableCache !==
null ) {
355 function ( $oldValue, &$ttl, &$setOpts ) {
357 $setOpts += Database::getCacheSetOptions(
$dbr );
362 $this->tableCache =
$table;
378 'id' => $this->idField,
379 'name' => $this->nameField
383 [
'ORDER BY' =>
'id' ]
387 foreach ( $result as $row ) {
388 $assocArray[$row->id] = $row->name;
401 Assert::parameterType(
'string', $name,
'$name' );
402 Assert::parameter( $name !==
'',
'$name',
'should not be an empty string' );
408 $dbw->doAtomicSection(
411 use ( $name, &$id, $dbw ) {
422 if ( $dbw->affectedRows() === 0 ) {
424 'Tried to insert name into table ' . $this->table .
', but value already existed.'
430 $id = $dbw->insertId();
434 $dbw->onAtomicSectionCancel(
435 function ( $trigger,
IDatabase $unused ) use ( $name, $id, $dbw ) {
440 IDatabase::ATOMIC_CANCELABLE
463 function (
IDatabase $unused,
$fname ) use ( $name, $id, &$ok, $dbw ) {
476 function ( $trigger,
IDatabase $unused ) use ( $name, $id, $dbw ) {
477 $this->logger->warning(
478 'Re-insertion of name into table ' . $this->
table
479 .
' was rolled back. Giving up and reloading the cache.'
481 $this->
reloadMap( ILoadBalancer::CONN_TRX_AUTOCOMMIT );
487 'Re-insert name into table ' . $this->
table .
' after failed transaction.'
490 IDatabase::ATOMIC_CANCELABLE
492 }
catch ( Exception $ex ) {
493 $this->logger->error(
494 'Re-insertion of name into table ' . $this->
table .
' failed: ' . $ex->getMessage()
508 $this->
reloadMap( ILoadBalancer::CONN_TRX_AUTOCOMMIT );
522 if ( $id !==
null ) {
526 if ( $this->insertCallback !==
null ) {
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Multi-datacenter aware caching interface.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if so it s not worth the trouble Since there is a job queue in the jobs table
Allows to change the fields on the form that will be generated $name
Generic interface for lightweight expiring object stores.
you have access to all of the normal MediaWiki so you can get a DB use the cache