params ) ) ); if ( $missing != '' ) { throw new InvalidArgumentException( "Missing parameter(s) $missing" ); } $this->removeDuplicates = true; } public function run() { $services = MediaWikiServices::getInstance(); $dbProvider = $services->getConnectionProvider(); $rowsPerQuery = $services->getMainConfig()->get( MainConfigNames::UpdateRowsPerQuery ); $dbw = $dbProvider->getPrimaryDatabase(); $ticket = $dbProvider->getEmptyTransactionTicket( __METHOD__ ); if ( !isset( $this->params['timestamp'] ) ) { $timestamp = null; $timestampCond = $dbw->expr( 'wl_notificationtimestamp', '!=', null ); } else { $timestamp = $dbw->timestamp( $this->params['timestamp'] ); $timestampCond = $dbw->expr( 'wl_notificationtimestamp', '!=', $timestamp ) ->or( 'wl_notificationtimestamp', '=', null ); } // New notifications since the reset should not be cleared $casTimeCond = $dbw->expr( 'wl_notificationtimestamp', '<', $dbw->timestamp( $this->params['casTime'] ) ) ->or( 'wl_notificationtimestamp', '=', null ); $firstBatch = true; do { $idsToUpdate = $dbw->newSelectQueryBuilder() ->select( 'wl_id' ) ->from( 'watchlist' ) ->where( [ 'wl_user' => $this->params['userId'] ] ) ->andWhere( $timestampCond ) ->andWhere( $casTimeCond ) ->limit( $rowsPerQuery ) ->caller( __METHOD__ )->fetchFieldValues(); if ( $idsToUpdate ) { $dbw->newUpdateQueryBuilder() ->update( 'watchlist' ) ->set( [ 'wl_notificationtimestamp' => $timestamp ] ) ->where( [ 'wl_id' => $idsToUpdate ] ) ->andWhere( $casTimeCond ) ->caller( __METHOD__ )->execute(); if ( !$firstBatch ) { $dbProvider->commitAndWaitForReplication( __METHOD__, $ticket ); } $firstBatch = false; } } while ( $idsToUpdate ); return true; } } /** @deprecated class alias since 1.43 */ class_alias( ClearWatchlistNotificationsJob::class, 'ClearWatchlistNotificationsJob' );