49 public function run() {
50 $services = MediaWikiServices::getInstance();
51 $dbProvider = $services->getConnectionProvider();
52 $rowsPerQuery = $services->getMainConfig()->get( MainConfigNames::UpdateRowsPerQuery );
54 $dbw = $dbProvider->getPrimaryDatabase();
55 $ticket = $dbProvider->getEmptyTransactionTicket( __METHOD__ );
56 if ( !isset( $this->params[
'timestamp'] ) ) {
58 $timestampCond = $dbw->expr(
'wl_notificationtimestamp',
'!=',
null );
60 $timestamp = $dbw->timestamp( $this->params[
'timestamp'] );
61 $timestampCond = $dbw->expr(
'wl_notificationtimestamp',
'!=', $timestamp )
62 ->or(
'wl_notificationtimestamp',
'=',
null );
65 $casTimeCond = $dbw->expr(
'wl_notificationtimestamp',
'<', $dbw->timestamp( $this->params[
'casTime'] ) )
66 ->or(
'wl_notificationtimestamp',
'=',
null );
70 $idsToUpdate = $dbw->newSelectQueryBuilder()
73 ->where( [
'wl_user' => $this->params[
'userId'] ] )
74 ->andWhere( $timestampCond )
75 ->andWhere( $casTimeCond )
76 ->limit( $rowsPerQuery )
77 ->caller( __METHOD__ )->fetchFieldValues();
80 $dbw->newUpdateQueryBuilder()
81 ->update(
'watchlist' )
82 ->set( [
'wl_notificationtimestamp' => $timestamp ] )
83 ->where( [
'wl_id' => $idsToUpdate ] )
84 ->andWhere( $casTimeCond )
85 ->caller( __METHOD__ )->execute();
87 $dbProvider->commitAndWaitForReplication( __METHOD__, $ticket );
91 }
while ( $idsToUpdate );