<?php
use MediaWiki\MediaWikiServices;
+use MediaWiki\User\UserIdentity;
/**
* Job to clear a users watchlist in batches.
* @ingroup JobQueue
* @since 1.31
*/
-class ClearUserWatchlistJob extends Job {
-
- /**
- * @param User $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( User $user, $maxWatchlistId ) {
- return new self(
- null,
- [ 'userId' => $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'];
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;