&& !$this->manager->getAuthenticationSessionData( 'no-email' )
) {
// TODO show 'confirmemail_oncreate'/'confirmemail_sendfailed' message
- wfGetDB( DB_MASTER )->onTransactionIdle( function () use ( $user ) {
- $user = $user->getInstanceForUpdate();
- $status = $user->sendConfirmationMail();
- $user->saveSettings();
- if ( !$status->isGood() ) {
- $this->logger->warning( 'Could not send confirmation email: ' .
- $status->getWikiText( false, false, 'en' ) );
- }
- } );
+ wfGetDB( DB_MASTER )->onTransactionIdle(
+ function () use ( $user ) {
+ $user = $user->getInstanceForUpdate();
+ $status = $user->sendConfirmationMail();
+ $user->saveSettings();
+ if ( !$status->isGood() ) {
+ $this->logger->warning( 'Could not send confirmation email: ' .
+ $status->getWikiText( false, false, 'en' ) );
+ }
+ },
+ __METHOD__
+ );
}
return AuthenticationResponse::newPass();
if ( $sendMail ) {
// Send email after DB commit
- $dbw->onTransactionIdle( function () use ( $req ) {
- /** @var TemporaryPasswordAuthenticationRequest $req */
- $this->sendPasswordResetEmail( $req );
- } );
+ $dbw->onTransactionIdle(
+ function () use ( $req ) {
+ /** @var TemporaryPasswordAuthenticationRequest $req */
+ $this->sendPasswordResetEmail( $req );
+ },
+ __METHOD__
+ );
}
}
if ( $mailpassword ) {
// Send email after DB commit
- wfGetDB( DB_MASTER )->onTransactionIdle( function () use ( $user, $creator, $req ) {
- $this->sendNewAccountEmail( $user, $creator, $req->password );
- } );
+ wfGetDB( DB_MASTER )->onTransactionIdle(
+ function () use ( $user, $creator, $req ) {
+ $this->sendNewAccountEmail( $user, $creator, $req->password );
+ },
+ __METHOD__
+ );
}
return $mailpassword ? 'byemail' : null;
) {
// @FIXME: This would be better as an extension hook
// Send emails or email jobs once this row is safely committed
- $dbw->onTransactionIdle( function () use ( $editor, $title ) {
- $enotif = new EmailNotification();
- $enotif->notifyOnPageChange(
- $editor,
- $title,
- $this->mAttribs['rc_timestamp'],
- $this->mAttribs['rc_comment'],
- $this->mAttribs['rc_minor'],
- $this->mAttribs['rc_last_oldid'],
- $this->mExtra['pageStatus']
- );
- } );
+ $dbw->onTransactionIdle(
+ function () use ( $editor, $title ) {
+ $enotif = new EmailNotification();
+ $enotif->notifyOnPageChange(
+ $editor,
+ $title,
+ $this->mAttribs['rc_timestamp'],
+ $this->mAttribs['rc_comment'],
+ $this->mAttribs['rc_minor'],
+ $this->mAttribs['rc_last_oldid'],
+ $this->mExtra['pageStatus']
+ );
+ },
+ __METHOD__
+ );
}
}
protected $mTrxPreCommitCallbacks = [];
/** @var array[] List of (callable, method name) */
protected $mTrxEndCallbacks = [];
- /** @var array[] Map of (name => (callable, method name)) */
+ /** @var callable[] Map of (name => callable) */
protected $mTrxRecurringCallbacks = [];
/** @var bool Whether to suppress triggering of transaction end callbacks */
protected $mTrxEndCallbacksSuppressed = false;
return false;
}
- final public function onTransactionResolution( callable $callback ) {
+ final public function onTransactionResolution( callable $callback, $fname = __METHOD__ ) {
if ( !$this->mTrxLevel ) {
throw new DBUnexpectedError( $this, "No transaction is active." );
}
- $this->mTrxEndCallbacks[] = [ $callback, wfGetCaller() ];
+ $this->mTrxEndCallbacks[] = [ $callback, $fname ];
}
- final public function onTransactionIdle( callable $callback ) {
- $this->mTrxIdleCallbacks[] = [ $callback, wfGetCaller() ];
+ final public function onTransactionIdle( callable $callback, $fname = __METHOD__ ) {
+ $this->mTrxIdleCallbacks[] = [ $callback, $fname ];
if ( !$this->mTrxLevel ) {
$this->runOnTransactionIdleCallbacks( self::TRIGGER_IDLE );
}
}
- final public function onTransactionPreCommitOrIdle( callable $callback ) {
+ final public function onTransactionPreCommitOrIdle( callable $callback, $fname = __METHOD__ ) {
if ( $this->mTrxLevel ) {
- $this->mTrxPreCommitCallbacks[] = [ $callback, wfGetCaller() ];
+ $this->mTrxPreCommitCallbacks[] = [ $callback, $fname ];
} else {
// If no transaction is active, then make one for this callback
$this->startAtomic( __METHOD__ );
final public function setTransactionListener( $name, callable $callback = null ) {
if ( $callback ) {
- $this->mTrxRecurringCallbacks[$name] = [ $callback, wfGetCaller() ];
+ $this->mTrxRecurringCallbacks[$name] = $callback;
} else {
unset( $this->mTrxRecurringCallbacks[$name] );
}
/** @var Exception $e */
$e = null; // first exception
- foreach ( $this->mTrxRecurringCallbacks as $callback ) {
+ foreach ( $this->mTrxRecurringCallbacks as $phpCallback ) {
try {
- list( $phpCallback ) = $callback;
$phpCallback( $trigger, $this );
} catch ( Exception $ex ) {
call_user_func( $this->errorLogger, $ex );
// There is a good chance an exception was thrown, causing any early return
// from the caller. Let any error handler get a chance to issue rollback().
// If there isn't one, let the error bubble up and trigger server-side rollback.
- $this->onTransactionResolution( function () use ( $lockKey, $fname ) {
- $this->unlock( $lockKey, $fname );
- } );
+ $this->onTransactionResolution(
+ function () use ( $lockKey, $fname ) {
+ $this->unlock( $lockKey, $fname );
+ },
+ $fname
+ );
} else {
$this->unlock( $lockKey, $fname );
}
} );
- $this->commit( __METHOD__, self::FLUSHING_INTERNAL );
+ $this->commit( $fname, self::FLUSHING_INTERNAL );
return $unlocker;
}
$this->callback = $callback;
if ( $this->dbw->trxLevel() ) {
- $this->dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ] );
+ $this->dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname );
}
}
$this->callback = $callback;
if ( $this->dbw->trxLevel() ) {
- $this->dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ] );
+ $this->dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname );
}
}
// Commit and release the lock (if set)
ScopedCallback::consume( $scopedLock );
// Run post-commit hooks without DBO_TRX
- $this->getDB()->onTransactionIdle( function() {
- Hooks::run( 'LinksUpdateComplete', [ &$this ] );
- } );
+ $this->getDB()->onTransactionIdle(
+ function () {
+ Hooks::run( 'LinksUpdateComplete', [ &$this ] );
+ },
+ __METHOD__
+ );
}
/**
$this->fname = $fname;
if ( $dbw && $dbw->trxLevel() ) {
- $dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ] );
+ $dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname );
}
}
function invalidateImageRedirect( Title $title ) {
$key = $this->getSharedCacheKey( 'image_redirect', md5( $title->getDBkey() ) );
if ( $key ) {
- $this->getMasterDB()->onTransactionPreCommitOrIdle( function() use ( $key ) {
- ObjectCache::getMainWANInstance()->delete( $key );
- } );
+ $this->getMasterDB()->onTransactionPreCommitOrIdle(
+ function () use ( $key ) {
+ ObjectCache::getMainWANInstance()->delete( $key );
+ },
+ __METHOD__
+ );
}
}
return;
}
- $this->repo->getMasterDB()->onTransactionPreCommitOrIdle( function() use ( $key ) {
- ObjectCache::getMainWANInstance()->delete( $key );
- } );
+ $this->repo->getMasterDB()->onTransactionPreCommitOrIdle(
+ function () use ( $key ) {
+ ObjectCache::getMainWANInstance()->delete( $key );
+ },
+ __METHOD__
+ );
}
/**
}
// Release the lock *after* commit to avoid row-level contention.
// Make sure it triggers on rollback() as well as commit() (T132921).
- $dbw->onTransactionResolution( function () use ( $logger ) {
- $status = $this->releaseFileLock();
- if ( !$status->isGood() ) {
- $logger->error( "Failed to unlock '{file}'", [ 'file' => $this->name ] );
- }
- } );
+ $dbw->onTransactionResolution(
+ function () use ( $logger ) {
+ $status = $this->releaseFileLock();
+ if ( !$status->isGood() ) {
+ $logger->error( "Failed to unlock '{file}'", [ 'file' => $this->name ] );
+ }
+ },
+ __METHOD__
+ );
// Callers might care if the SELECT snapshot is safely fresh
$this->lockedOwnTrx = $makesTransaction;
}
$dbw->onTransactionIdle(
function () use ( $dbw, $jobs, $flags, $method ) {
$this->doBatchPushInternal( $dbw, $jobs, $flags, $method );
- }
+ },
+ __METHOD__
);
}
// jobs to become no-ops without any actual jobs that made them redundant.
$dbw = $this->getMasterDB();
$cache = $this->dupCache;
- $dbw->onTransactionIdle( function () use ( $cache, $params, $key, $dbw ) {
- $timestamp = $cache->get( $key ); // current last timestamp of this job
- if ( $timestamp && $timestamp >= $params['rootJobTimestamp'] ) {
- return true; // a newer version of this root job was enqueued
- }
+ $dbw->onTransactionIdle(
+ function () use ( $cache, $params, $key, $dbw ) {
+ $timestamp = $cache->get( $key ); // current last timestamp of this job
+ if ( $timestamp && $timestamp >= $params['rootJobTimestamp'] ) {
+ return true; // a newer version of this root job was enqueued
+ }
- // Update the timestamp of the last root job started at the location...
- return $cache->set( $key, $params['rootJobTimestamp'], JobQueueDB::ROOTJOB_TTL );
- } );
+ // Update the timestamp of the last root job started at the location...
+ return $cache->set( $key, $params['rootJobTimestamp'], JobQueueDB::ROOTJOB_TTL );
+ },
+ __METHOD__
+ );
return true;
}
* @author Aaron Schulz
* @ingroup JobQueue
*/
+use MediaWiki\MediaWikiServices;
/**
* Job for pruning recent changes
return; // already in progress
}
- $factory = wfGetLBFactory();
+ $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
$ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
$cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
do {
$dbw = wfGetDB( DB_MASTER );
// JobRunner uses DBO_TRX, but doesn't call begin/commit itself;
// onTransactionIdle() will run immediately since there is no trx.
- $dbw->onTransactionIdle( function() use ( $dbw, $days, $window ) {
- $factory = wfGetLBFactory();
- $ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
- // Avoid disconnect/ping() cycle that makes locks fall off
- $dbw->setSessionOptions( [ 'connTimeout' => 900 ] );
-
- $lockKey = wfWikiID() . '-activeusers';
- if ( !$dbw->lock( $lockKey, __METHOD__, 1 ) ) {
- return; // exclusive update (avoids duplicate entries)
- }
-
- $nowUnix = time();
- // Get the last-updated timestamp for the cache
- $cTime = $dbw->selectField( 'querycache_info',
- 'qci_timestamp',
- [ 'qci_type' => 'activeusers' ]
- );
- $cTimeUnix = $cTime ? wfTimestamp( TS_UNIX, $cTime ) : 1;
-
- // Pick the date range to fetch from. This is normally from the last
- // update to till the present time, but has a limited window for sanity.
- // If the window is limited, multiple runs are need to fully populate it.
- $sTimestamp = max( $cTimeUnix, $nowUnix - $days * 86400 );
- $eTimestamp = min( $sTimestamp + $window, $nowUnix );
-
- // Get all the users active since the last update
- $res = $dbw->select(
- [ 'recentchanges' ],
- [ 'rc_user_text', 'lastedittime' => 'MAX(rc_timestamp)' ],
- [
- 'rc_user > 0', // actual accounts
- 'rc_type != ' . $dbw->addQuotes( RC_EXTERNAL ), // no wikidata
- 'rc_log_type IS NULL OR rc_log_type != ' . $dbw->addQuotes( 'newusers' ),
- 'rc_timestamp >= ' . $dbw->addQuotes( $dbw->timestamp( $sTimestamp ) ),
- 'rc_timestamp <= ' . $dbw->addQuotes( $dbw->timestamp( $eTimestamp ) )
- ],
- __METHOD__,
- [
- 'GROUP BY' => [ 'rc_user_text' ],
- 'ORDER BY' => 'NULL' // avoid filesort
- ]
- );
- $names = [];
- foreach ( $res as $row ) {
- $names[$row->rc_user_text] = $row->lastedittime;
- }
-
- // Rotate out users that have not edited in too long (according to old data set)
- $dbw->delete( 'querycachetwo',
- [
- 'qcc_type' => 'activeusers',
- 'qcc_value < ' . $dbw->addQuotes( $nowUnix - $days * 86400 ) // TS_UNIX
- ],
- __METHOD__
- );
+ $dbw->onTransactionIdle(
+ function () use ( $dbw, $days, $window ) {
+ $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+ $ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
+ // Avoid disconnect/ping() cycle that makes locks fall off
+ $dbw->setSessionOptions( [ 'connTimeout' => 900 ] );
+
+ $lockKey = wfWikiID() . '-activeusers';
+ if ( !$dbw->lock( $lockKey, __METHOD__, 1 ) ) {
+ return; // exclusive update (avoids duplicate entries)
+ }
- // Find which of the recently active users are already accounted for
- if ( count( $names ) ) {
- $res = $dbw->select( 'querycachetwo',
- [ 'user_name' => 'qcc_title' ],
+ $nowUnix = time();
+ // Get the last-updated timestamp for the cache
+ $cTime = $dbw->selectField( 'querycache_info',
+ 'qci_timestamp',
+ [ 'qci_type' => 'activeusers' ]
+ );
+ $cTimeUnix = $cTime ? wfTimestamp( TS_UNIX, $cTime ) : 1;
+
+ // Pick the date range to fetch from. This is normally from the last
+ // update to till the present time, but has a limited window for sanity.
+ // If the window is limited, multiple runs are need to fully populate it.
+ $sTimestamp = max( $cTimeUnix, $nowUnix - $days * 86400 );
+ $eTimestamp = min( $sTimestamp + $window, $nowUnix );
+
+ // Get all the users active since the last update
+ $res = $dbw->select(
+ [ 'recentchanges' ],
+ [ 'rc_user_text', 'lastedittime' => 'MAX(rc_timestamp)' ],
[
- 'qcc_type' => 'activeusers',
- 'qcc_namespace' => NS_USER,
- 'qcc_title' => array_keys( $names ) ],
- __METHOD__
+ 'rc_user > 0', // actual accounts
+ 'rc_type != ' . $dbw->addQuotes( RC_EXTERNAL ), // no wikidata
+ 'rc_log_type IS NULL OR rc_log_type != ' . $dbw->addQuotes( 'newusers' ),
+ 'rc_timestamp >= ' . $dbw->addQuotes( $dbw->timestamp( $sTimestamp ) ),
+ 'rc_timestamp <= ' . $dbw->addQuotes( $dbw->timestamp( $eTimestamp ) )
+ ],
+ __METHOD__,
+ [
+ 'GROUP BY' => [ 'rc_user_text' ],
+ 'ORDER BY' => 'NULL' // avoid filesort
+ ]
);
+ $names = [];
foreach ( $res as $row ) {
- unset( $names[$row->user_name] );
+ $names[$row->rc_user_text] = $row->lastedittime;
}
- }
- // Insert the users that need to be added to the list
- if ( count( $names ) ) {
- $newRows = [];
- foreach ( $names as $name => $lastEditTime ) {
- $newRows[] = [
+ // Rotate out users that have not edited in too long (according to old data set)
+ $dbw->delete( 'querycachetwo',
+ [
'qcc_type' => 'activeusers',
- 'qcc_namespace' => NS_USER,
- 'qcc_title' => $name,
- 'qcc_value' => wfTimestamp( TS_UNIX, $lastEditTime ),
- 'qcc_namespacetwo' => 0, // unused
- 'qcc_titletwo' => '' // unused
- ];
+ 'qcc_value < ' . $dbw->addQuotes( $nowUnix - $days * 86400 ) // TS_UNIX
+ ],
+ __METHOD__
+ );
+
+ // Find which of the recently active users are already accounted for
+ if ( count( $names ) ) {
+ $res = $dbw->select( 'querycachetwo',
+ [ 'user_name' => 'qcc_title' ],
+ [
+ 'qcc_type' => 'activeusers',
+ 'qcc_namespace' => NS_USER,
+ 'qcc_title' => array_keys( $names ) ],
+ __METHOD__
+ );
+ foreach ( $res as $row ) {
+ unset( $names[$row->user_name] );
+ }
}
- foreach ( array_chunk( $newRows, 500 ) as $rowBatch ) {
- $dbw->insert( 'querycachetwo', $rowBatch, __METHOD__ );
- $factory->commitAndWaitForReplication( __METHOD__, $ticket );
+
+ // Insert the users that need to be added to the list
+ if ( count( $names ) ) {
+ $newRows = [];
+ foreach ( $names as $name => $lastEditTime ) {
+ $newRows[] = [
+ 'qcc_type' => 'activeusers',
+ 'qcc_namespace' => NS_USER,
+ 'qcc_title' => $name,
+ 'qcc_value' => wfTimestamp( TS_UNIX, $lastEditTime ),
+ 'qcc_namespacetwo' => 0, // unused
+ 'qcc_titletwo' => '' // unused
+ ];
+ }
+ foreach ( array_chunk( $newRows, 500 ) as $rowBatch ) {
+ $dbw->insert( 'querycachetwo', $rowBatch, __METHOD__ );
+ $factory->commitAndWaitForReplication( __METHOD__, $ticket );
+ }
}
- }
- // If a transaction was already started, it might have an old
- // snapshot, so kludge the timestamp range back as needed.
- $asOfTimestamp = min( $eTimestamp, (int)$dbw->trxTimestamp() );
+ // If a transaction was already started, it might have an old
+ // snapshot, so kludge the timestamp range back as needed.
+ $asOfTimestamp = min( $eTimestamp, (int)$dbw->trxTimestamp() );
- // Touch the data freshness timestamp
- $dbw->replace( 'querycache_info',
- [ 'qci_type' ],
- [ 'qci_type' => 'activeusers',
- 'qci_timestamp' => $dbw->timestamp( $asOfTimestamp ) ], // not always $now
- __METHOD__
- );
+ // Touch the data freshness timestamp
+ $dbw->replace( 'querycache_info',
+ [ 'qci_type' ],
+ [ 'qci_type' => 'activeusers',
+ 'qci_timestamp' => $dbw->timestamp( $asOfTimestamp ) ], // not always $now
+ __METHOD__
+ );
- $dbw->unlock( $lockKey, __METHOD__ );
- } );
+ $dbw->unlock( $lockKey, __METHOD__ );
+ },
+ __METHOD__
+ );
}
}
return;
}
- $dbw->onTransactionIdle( function() use ( $dbw, $namespace, $dbkeys ) {
- $services = MediaWikiServices::getInstance();
- $lbFactory = $services->getDBLoadBalancerFactory();
- // Determine which pages need to be updated.
- // This is necessary to prevent the job queue from smashing the DB with
- // large numbers of concurrent invalidations of the same page.
- $now = $dbw->timestamp();
- $ids = $dbw->selectFieldValues(
- 'page',
- 'page_id',
- [
- 'page_namespace' => $namespace,
- 'page_title' => $dbkeys,
- 'page_touched < ' . $dbw->addQuotes( $now )
- ],
- __METHOD__
- );
-
- if ( !$ids ) {
- return;
- }
-
- $batchSize = $services->getMainConfig()->get( 'UpdateRowsPerQuery' );
- $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
- foreach ( array_chunk( $ids, $batchSize ) as $idBatch ) {
- $dbw->update(
+ $dbw->onTransactionIdle(
+ function () use ( $dbw, $namespace, $dbkeys ) {
+ $services = MediaWikiServices::getInstance();
+ $lbFactory = $services->getDBLoadBalancerFactory();
+ // Determine which pages need to be updated.
+ // This is necessary to prevent the job queue from smashing the DB with
+ // large numbers of concurrent invalidations of the same page.
+ $now = $dbw->timestamp();
+ $ids = $dbw->selectFieldValues(
'page',
- [ 'page_touched' => $now ],
+ 'page_id',
[
- 'page_id' => $idBatch,
- 'page_touched < ' . $dbw->addQuotes( $now ) // handle races
+ 'page_namespace' => $namespace,
+ 'page_title' => $dbkeys,
+ 'page_touched < ' . $dbw->addQuotes( $now )
],
__METHOD__
);
- $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
- }
- } );
+
+ if ( !$ids ) {
+ return;
+ }
+
+ $batchSize = $services->getMainConfig()->get( 'UpdateRowsPerQuery' );
+ $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
+ foreach ( array_chunk( $ids, $batchSize ) as $idBatch ) {
+ $dbw->update(
+ 'page',
+ [ 'page_touched' => $now ],
+ [
+ 'page_id' => $idBatch,
+ 'page_touched < ' . $dbw->addQuotes( $now ) // handle races
+ ],
+ __METHOD__
+ );
+ $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
+ }
+ },
+ __METHOD__
+ );
}
}
return $this->__call( __FUNCTION__, func_get_args() );
}
- public function onTransactionResolution( callable $callback ) {
+ public function onTransactionResolution( callable $callback, $fname = __METHOD__ ) {
return $this->__call( __FUNCTION__, func_get_args() );
}
- public function onTransactionIdle( callable $callback ) {
+ public function onTransactionIdle( callable $callback, $fname = __METHOD__ ) {
return $this->__call( __FUNCTION__, func_get_args() );
}
- public function onTransactionPreCommitOrIdle( callable $callback ) {
+ public function onTransactionPreCommitOrIdle( callable $callback, $fname = __METHOD__ ) {
return $this->__call( __FUNCTION__, func_get_args() );
}
* - How the transaction ended (IDatabase::TRIGGER_COMMIT or IDatabase::TRIGGER_ROLLBACK)
*
* @param callable $callback
+ * @param string $fname Caller name
* @return mixed
* @since 1.28
*/
- public function onTransactionResolution( callable $callback );
+ public function onTransactionResolution( callable $callback, $fname = __METHOD__ );
/**
* Run a callback as soon as there is no transaction pending.
* - How the transaction ended (IDatabase::TRIGGER_COMMIT or IDatabase::TRIGGER_IDLE)
*
* @param callable $callback
+ * @param string $fname Caller name
* @since 1.20
*/
- public function onTransactionIdle( callable $callback );
+ public function onTransactionIdle( callable $callback, $fname = __METHOD__ );
/**
* Run a callback before the current transaction commits or now if there is none.
* Updates will execute in the order they were enqueued.
*
* @param callable $callback
+ * @param string $fname Caller name
* @since 1.22
*/
- public function onTransactionPreCommitOrIdle( callable $callback );
+ public function onTransactionPreCommitOrIdle( callable $callback, $fname = __METHOD__ );
/**
* Run a callback each time any transaction commits or rolls back
$logEntry->setComment( $reason );
$logid = $logEntry->insert();
- $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $logEntry, $logid ) {
- // Bug 56776: avoid deadlocks (especially from FileDeleteForm)
- $logEntry->publish( $logid );
- } );
+ $dbw->onTransactionPreCommitOrIdle(
+ function () use ( $dbw, $logEntry, $logid ) {
+ // Bug 56776: avoid deadlocks (especially from FileDeleteForm)
+ $logEntry->publish( $logid );
+ },
+ __METHOD__
+ );
$dbw->endAtomic( __METHOD__ );
$cat->refreshCounts();
}
}
- }
+ },
+ __METHOD__
);
}
);
if ( $dbw->trxLevel() ) {
- $dbw->onTransactionResolution( function () use ( &$scopeLock ) {
- ScopedCallback::consume( $scopeLock ); // release after commit
- } );
+ $dbw->onTransactionResolution(
+ function () use ( &$scopeLock ) {
+ ScopedCallback::consume( $scopeLock ); // release after commit
+ },
+ __METHOD__
+ );
}
}
} catch ( Exception $e ) {
}
$dbw->startAtomic( __METHOD__ );
- $dbw->onTransactionResolution( function () {
- // Release locks on commit or error
- $this->releaseItemLocks();
- } );
+ $dbw->onTransactionResolution(
+ function () {
+ // Release locks on commit or error
+ $this->releaseItemLocks();
+ },
+ __METHOD__
+ );
$missing = array_flip( $this->ids );
$this->clearFileOps();
wfGetDB( DB_MASTER )->onTransactionPreCommitOrIdle(
function() use ( $cache, $key ) {
$cache->delete( $key );
- }
+ },
+ __METHOD__
);
}
}
* Deferred version of incEditCountImmediate()
*/
public function incEditCount() {
- wfGetDB( DB_MASTER )->onTransactionPreCommitOrIdle( function() {
- $this->incEditCountImmediate();
- } );
+ wfGetDB( DB_MASTER )->onTransactionPreCommitOrIdle(
+ function () {
+ $this->incEditCountImmediate();
+ },
+ __METHOD__
+ );
}
/**
* Replaces User::touchUser()
*/
function invalidateCache() {
- $this->db->update( 'user',
+ $this->db->update(
+ 'user',
[ 'user_touched' => $this->db->timestamp() ],
[ 'user_id' => $this->id ],
- __METHOD__ );
+ __METHOD__
+ );
$wikiId = $this->db->getWikiID();
$userId = $this->id;
- $this->db->onTransactionPreCommitOrIdle( function() use ( $wikiId, $userId ) {
- User::purge( $wikiId, $userId );
- } );
+ $this->db->onTransactionPreCommitOrIdle(
+ function () use ( $wikiId, $userId ) {
+ User::purge( $wikiId, $userId );
+ },
+ __METHOD__
+ );
}
}
}
$this->db->restoreFlags( IDatabase::RESTORE_INITIAL );
}
+
/**
* @covers DatabaseBase::dropTable
*/
private function dropFunctions() {
$this->db->query( 'DROP FUNCTION IF EXISTS mw_test_function'
- . ( $this->db->getType() == 'postgres' ? '()' : '' )
+ . ( $this->db->getType() == 'postgres' ? '()' : '' )
);
}
$db->setFlag( DBO_TRX );
$called = false;
$flagSet = null;
- $db->onTransactionIdle( function() use ( $db, &$flagSet, &$called ) {
- $called = true;
- $flagSet = $db->getFlag( DBO_TRX );
- } );
+ $db->onTransactionIdle(
+ function () use ( $db, &$flagSet, &$called ) {
+ $called = true;
+ $flagSet = $db->getFlag( DBO_TRX );
+ },
+ __METHOD__
+ );
$this->assertFalse( $flagSet, 'DBO_TRX off in callback' );
$this->assertTrue( $db->getFlag( DBO_TRX ), 'DBO_TRX restored to default' );
$this->assertTrue( $called, 'Callback reached' );
$db->clearFlag( DBO_TRX );
$flagSet = null;
- $db->onTransactionIdle( function() use ( $db, &$flagSet ) {
- $flagSet = $db->getFlag( DBO_TRX );
- } );
+ $db->onTransactionIdle(
+ function () use ( $db, &$flagSet ) {
+ $flagSet = $db->getFlag( DBO_TRX );
+ },
+ __METHOD__
+ );
$this->assertFalse( $flagSet, 'DBO_TRX off in callback' );
$this->assertFalse( $db->getFlag( DBO_TRX ), 'DBO_TRX restored to default' );
$db->clearFlag( DBO_TRX );
- $db->onTransactionIdle( function() use ( $db ) {
- $db->setFlag( DBO_TRX );
- } );
+ $db->onTransactionIdle(
+ function () use ( $db ) {
+ $db->setFlag( DBO_TRX );
+ },
+ __METHOD__
+ );
$this->assertFalse( $db->getFlag( DBO_TRX ), 'DBO_TRX restored to default' );
}
$db->clearFlag( DBO_TRX );
$db->begin( __METHOD__ );
$called = false;
- $db->onTransactionResolution( function() use ( $db, &$called ) {
+ $db->onTransactionResolution( function () use ( $db, &$called ) {
$called = true;
$db->setFlag( DBO_TRX );
} );
$db->clearFlag( DBO_TRX );
$db->begin( __METHOD__ );
$called = false;
- $db->onTransactionResolution( function() use ( $db, &$called ) {
+ $db->onTransactionResolution( function () use ( $db, &$called ) {
$called = true;
$db->setFlag( DBO_TRX );
} );
public function testTransactionListener() {
$db = $this->db;
- $db->setTransactionListener( 'ping', function() use ( $db, &$called ) {
+ $db->setTransactionListener( 'ping', function () use ( $db, &$called ) {
$called = true;
} );