Merge "Add MessagesBi.php"
[lhc/web/wiklou.git] / includes / watcheditem / WatchedItemStore.php
index 1b37968..6b0c2aa 100644 (file)
@@ -407,6 +407,11 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
                array $targetsWithVisitThresholds,
                $minimumWatchers = null
        ) {
+               if ( $targetsWithVisitThresholds === [] ) {
+                       // No titles requested => no results returned
+                       return [];
+               }
+
                $dbr = $this->getConnectionRef( DB_REPLICA );
 
                $conds = $this->getVisitingWatchersCondition( $dbr, $targetsWithVisitThresholds );
@@ -504,7 +509,7 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
         * @since 1.27
         * @param User $user
         * @param LinkTarget $target
-        * @return bool
+        * @return WatchedItem|bool
         */
        public function loadWatchedItem( User $user, LinkTarget $target ) {
                // Only loggedin user can have a watchlist
@@ -765,12 +770,34 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
                return $success;
        }
 
+       public function resetAllNotificationTimestampsForUser( User $user ) {
+               // Only loggedin user can have a watchlist
+               if ( $user->isAnon() ) {
+                       return;
+               }
+
+               // If the page is watched by the user (or may be watched), update the timestamp
+               $job = new ClearWatchlistNotificationsJob(
+                       $user->getUserPage(),
+                       [ 'userId'  => $user->getId(), 'casTime' => time() ]
+               );
+
+               // Try to run this post-send
+               // Calls DeferredUpdates::addCallableUpdate in normal operation
+               call_user_func(
+                       $this->deferredUpdatesAddCallableUpdateCallback,
+                       function () use ( $job ) {
+                               $job->run();
+                       }
+               );
+       }
+
        /**
         * @since 1.27
         * @param User $editor
         * @param LinkTarget $target
         * @param string|int $timestamp
-        * @return int
+        * @return int[]
         */
        public function updateNotificationTimestamp( User $editor, LinkTarget $target, $timestamp ) {
                $dbw = $this->getConnectionRef( DB_MASTER );