Display the file sha1 value in the file info page
[lhc/web/wiklou.git] / includes / watcheditem / WatchedItemStore.php
index 094297c..f29bd47 100644 (file)
@@ -212,6 +212,33 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
                return $this->loadBalancer->getConnectionRef( $dbIndex, [ 'watchlist' ] );
        }
 
+       /**
+        * Queues a job that will clear the users watchlist using the Job Queue.
+        *
+        * @since 1.31
+        *
+        * @param User $user
+        */
+       public function clearUserWatchedItemsUsingJobQueue( User $user ) {
+               $job = ClearUserWatchlistJob::newForUser( $user, $this->getMaxId() );
+               // TODO inject me.
+               JobQueueGroup::singleton()->push( $job );
+       }
+
+       /**
+        * @since 1.31
+        * @return int The maximum current wl_id
+        */
+       public function getMaxId() {
+               $dbr = $this->getConnectionRef( DB_REPLICA );
+               return (int)$dbr->selectField(
+                       'watchlist',
+                       'MAX(wl_id)',
+                       '',
+                       __METHOD__
+               );
+       }
+
        /**
         * @since 1.31
         */