X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjobqueue%2Fjobs%2FRecentChangesUpdateJob.php;h=d97e4f9ad38eff03518fedb64822347bcb26439c;hb=b4e9b1ba621d77b580cfd5b19e927ccaec54831a;hp=ca57d6234098796347d4c1571a9f026ade893def;hpb=946e506a91f4a6f3dbe50c29ab255ea8614a8dce;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/jobqueue/jobs/RecentChangesUpdateJob.php b/includes/jobqueue/jobs/RecentChangesUpdateJob.php index ca57d62340..d97e4f9ad3 100644 --- a/includes/jobqueue/jobs/RecentChangesUpdateJob.php +++ b/includes/jobqueue/jobs/RecentChangesUpdateJob.php @@ -76,24 +76,33 @@ class RecentChangesUpdateJob extends Job { $lockKey = wfWikiID() . ':recentchanges-prune'; $dbw = wfGetDB( DB_MASTER ); - if ( !$dbw->lockIsFree( $lockKey, __METHOD__ ) - || !$dbw->lock( $lockKey, __METHOD__, 1 ) - ) { - return; // already in progress + if ( !$dbw->lock( $lockKey, __METHOD__, 0 ) ) { + // already in progress + return; } $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); $ticket = $factory->getEmptyTransactionTicket( __METHOD__ ); $cutoff = $dbw->timestamp( time() - $wgRCMaxAge ); + $rcQuery = RecentChange::getQueryInfo(); do { - $rcIds = $dbw->selectFieldValues( 'recentchanges', - 'rc_id', + $rcIds = []; + $rows = []; + $res = $dbw->select( + $rcQuery['tables'], + $rcQuery['fields'], [ 'rc_timestamp < ' . $dbw->addQuotes( $cutoff ) ], __METHOD__, - [ 'LIMIT' => $wgUpdateRowsPerQuery ] + [ 'LIMIT' => $wgUpdateRowsPerQuery ], + $rcQuery['joins'] ); + foreach ( $res as $row ) { + $rcIds[] = $row->rc_id; + $rows[] = $row; + } if ( $rcIds ) { $dbw->delete( 'recentchanges', [ 'rc_id' => $rcIds ], __METHOD__ ); + Hooks::run( 'RecentChangesPurgeRows', [ $rows ] ); // There might be more, so try waiting for replica DBs try { $factory->commitAndWaitForReplication( @@ -128,7 +137,7 @@ class RecentChangesUpdateJob extends Job { $dbw->setSessionOptions( [ 'connTimeout' => 900 ] ); $lockKey = wfWikiID() . '-activeusers'; - if ( !$dbw->lockIsFree( $lockKey, __METHOD__ ) || !$dbw->lock( $lockKey, __METHOD__, 1 ) ) { + if ( !$dbw->lock( $lockKey, __METHOD__, 0 ) ) { // Exclusive update (avoids duplicate entries)… it's usually fine to just drop out here, // if the Job is already running. return;