*
* @file
*/
+use Wikimedia\Rdbms\IDatabase;
use MediaWiki\MediaWikiServices;
class PurgeJobUtils {
if ( $dbkeys === [] ) {
return;
}
+ $fname = __METHOD__;
- $dbw->onTransactionIdle(
- function () use ( $dbw, $namespace, $dbkeys ) {
+ DeferredUpdates::addUpdate( new AutoCommitUpdate(
+ $dbw,
+ __METHOD__,
+ function () use ( $dbw, $namespace, $dbkeys, $fname ) {
$services = MediaWikiServices::getInstance();
$lbFactory = $services->getDBLoadBalancerFactory();
// Determine which pages need to be updated.
'page_title' => $dbkeys,
'page_touched < ' . $dbw->addQuotes( $now )
],
- __METHOD__
+ $fname
);
if ( !$ids ) {
}
$batchSize = $services->getMainConfig()->get( 'UpdateRowsPerQuery' );
- $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
- foreach ( array_chunk( $ids, $batchSize ) as $idBatch ) {
+ $ticket = $lbFactory->getEmptyTransactionTicket( $fname );
+ $idBatches = array_chunk( $ids, $batchSize );
+ foreach ( $idBatches as $idBatch ) {
$dbw->update(
'page',
[ 'page_touched' => $now ],
'page_id' => $idBatch,
'page_touched < ' . $dbw->addQuotes( $now ) // handle races
],
- __METHOD__
+ $fname
);
- $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
+ if ( count( $idBatches ) > 1 ) {
+ $lbFactory->commitAndWaitForReplication( $fname, $ticket );
+ }
}
- },
- __METHOD__
- );
+ }
+ ) );
}
}