X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fjobqueue%2Fjobs%2FClearUserWatchlistJob.php;h=0cb1a52d694f860d1e1722b60781e1d4e7bcfcb3;hp=77adfa1a9435a38a310c67e9474584e2f0b9f4e5;hb=a9164f143a59a8d957a1d7f205715ac57fff3c8c;hpb=3196cacb552900bc4f416897084c358f75c46596 diff --git a/includes/jobqueue/jobs/ClearUserWatchlistJob.php b/includes/jobqueue/jobs/ClearUserWatchlistJob.php index 77adfa1a94..0cb1a52d69 100644 --- a/includes/jobqueue/jobs/ClearUserWatchlistJob.php +++ b/includes/jobqueue/jobs/ClearUserWatchlistJob.php @@ -1,6 +1,7 @@ $user->getId(), 'maxWatchlistId' => $maxWatchlistId ] - ); - } - +class ClearUserWatchlistJob extends Job implements GenericParameterJob { /** - * @param Title|null $title Not used by this job. * @param array $params * - 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 ) { - parent::__construct( - 'clearUserWatchlist', - SpecialPage::getTitleFor( 'EditWatchlist', 'clear' ), - $params - ); + public function __construct( array $params ) { + parent::__construct( 'clearUserWatchlist', $params ); $this->removeDuplicates = true; } + /** + * @param UserIdentity $user User to clear the watchlist for. + * @param int $maxWatchlistId The maximum wl_id at the time the job was first created. + * + * @return ClearUserWatchlistJob + */ + public static function newForUser( UserIdentity $user, $maxWatchlistId ) { + return new self( [ 'userId' => $user->getId(), 'maxWatchlistId' => $maxWatchlistId ] ); + } + public function run() { global $wgUpdateRowsPerQuery; $userId = $this->params['userId']; @@ -101,7 +93,7 @@ class ClearUserWatchlistJob extends Job { 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() ) ); + JobQueueGroup::singleton()->push( new self( $this->getParams() ) ); } return true;