- // If the page is watched by the user (or may be watched), update the timestamp on any
- // any matching rows
- $dbw = wfGetDB( DB_MASTER );
- $dbw->update( 'watchlist', array( 'wl_notificationtimestamp' => $notificationTimestamp ),
- $this->dbCond(), __METHOD__ );
+ // If the page is watched by the user (or may be watched), update the timestamp
+ if ( $mode === self::DEFERRED ) {
+ $job = new ActivityUpdateJob(
+ $title,
+ array(
+ 'type' => 'updateWatchlistNotification',
+ 'userid' => $this->getUserId(),
+ 'notifTime' => $notificationTimestamp,
+ 'curTime' => time()
+ )
+ );
+ // Try to run this post-send
+ DeferredUpdates::addCallableUpdate( function() use ( $job ) {
+ $job->run();
+ } );
+ } else {
+ $dbw = wfGetDB( DB_MASTER );
+ $dbw->update( 'watchlist',
+ array( 'wl_notificationtimestamp' => $notificationTimestamp ),
+ $this->dbCond(),
+ __METHOD__
+ );
+ }
+