X-Git-Url: https://git.cyclocoop.org/%28%28?a=blobdiff_plain;f=includes%2Fjobqueue%2Fjobs%2FClearUserWatchlistJob.php;h=77adfa1a9435a38a310c67e9474584e2f0b9f4e5;hb=87f40138c64ddccb6dc6d54531cea02af40ef0f3;hp=17c4b665e2b1dbf9c823cce0f70d3dd8dbfb4188;hpb=55cb4d0065f625d074db50524525f9d28fee3ff8;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/jobqueue/jobs/ClearUserWatchlistJob.php b/includes/jobqueue/jobs/ClearUserWatchlistJob.php index 17c4b665e2..77adfa1a94 100644 --- a/includes/jobqueue/jobs/ClearUserWatchlistJob.php +++ b/includes/jobqueue/jobs/ClearUserWatchlistJob.php @@ -28,15 +28,10 @@ class ClearUserWatchlistJob extends Job { /** * @param Title|null $title Not used by this job. * @param array $params - * - batchSize, Number of watchlist entries to remove at once. * - userId, The ID for the user whose watchlist is being cleared. * - maxWatchlistId, The maximum wl_id at the time the job was first created, */ public function __construct( Title $title = null, array $params ) { - if ( !array_key_exists( 'batchSize', $params ) ) { - $params['batchSize'] = 1000; - } - parent::__construct( 'clearUserWatchlist', SpecialPage::getTitleFor( 'EditWatchlist', 'clear' ), @@ -47,8 +42,10 @@ class ClearUserWatchlistJob extends Job { } public function run() { + global $wgUpdateRowsPerQuery; $userId = $this->params['userId']; $maxWatchlistId = $this->params['maxWatchlistId']; + $batchSize = $wgUpdateRowsPerQuery; $loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer(); $dbw = $loadBalancer->getConnection( DB_MASTER ); @@ -56,7 +53,7 @@ class ClearUserWatchlistJob extends Job { // Wait before lock to try to reduce time waiting in the lock. if ( !$loadBalancer->safeWaitForMasterPos( $dbr ) ) { - $this->setLastError( 'Timed out while waiting for slave to catch up before lock' ); + $this->setLastError( 'Timed out waiting for replica to catch up before lock' ); return false; } @@ -69,7 +66,7 @@ class ClearUserWatchlistJob extends Job { } if ( !$loadBalancer->safeWaitForMasterPos( $dbr ) ) { - $this->setLastError( 'Timed out while waiting for slave to catch up within lock' ); + $this->setLastError( 'Timed out waiting for replica to catch up within lock' ); return false; } @@ -86,7 +83,7 @@ class ClearUserWatchlistJob extends Job { __METHOD__, [ 'ORDER BY' => 'wl_id ASC', - 'LIMIT' => $this->params['batchSize'], + 'LIMIT' => $batchSize, ] ); @@ -101,7 +98,9 @@ class ClearUserWatchlistJob extends Job { $lbf->commitMasterChanges( __METHOD__ ); unset( $scopedLock ); - if ( count( $watchlistIds ) == $this->params['batchSize'] ) { + if ( count( $watchlistIds ) === (int)$batchSize ) { + // Until we get less results than the limit, recursively push + // the same job again. JobQueueGroup::singleton()->push( new self( $this->getTitle(), $this->getParams() ) ); }