+ /**
+ * @param User $editor The editor that triggered the update. Their notification
+ * timestamp will not be updated(they have already seen it)
+ * @param Title $title The title to update timestamps for
+ * @param string $timestamp Set the upate timestamp to this value
+ * @return int[]
+ */
+ public static function updateWatchlistTimestamp( User $editor, Title $title, $timestamp ) {
+ global $wgEnotifWatchlist, $wgShowUpdatedMarker;
+
+ if ( !$wgEnotifWatchlist && !$wgShowUpdatedMarker ) {
+ return array();
+ }
+
+ $dbw = wfGetDB( DB_MASTER );
+ $res = $dbw->select( array( 'watchlist' ),
+ array( 'wl_user' ),
+ array(
+ 'wl_user != ' . intval( $editor->getID() ),
+ 'wl_namespace' => $title->getNamespace(),
+ 'wl_title' => $title->getDBkey(),
+ 'wl_notificationtimestamp IS NULL',
+ ), __METHOD__
+ );
+
+ $watchers = array();
+ foreach ( $res as $row ) {
+ $watchers[] = intval( $row->wl_user );
+ }
+
+ if ( $watchers ) {
+ // Update wl_notificationtimestamp for all watching users except the editor
+ $fname = __METHOD__;
+ $dbw->onTransactionIdle(
+ function () use ( $dbw, $timestamp, $watchers, $title, $fname ) {
+ $dbw->update( 'watchlist',
+ array( /* SET */
+ 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp )
+ ), array( /* WHERE */
+ 'wl_user' => $watchers,
+ 'wl_namespace' => $title->getNamespace(),
+ 'wl_title' => $title->getDBkey(),
+ ), $fname
+ );
+ }
+ );
+ }
+
+ return $watchers;
+ }
+