X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fwatcheditem%2FWatchedItemStore.php;h=6b0c2aab1104b371f56292d21a09f56ed2328933;hp=35e824e036eab6bd96ea915204209874408cc488;hb=4df0c71911500466a6330b8fe29c623ef5b51e41;hpb=61aab0ff9912221d51b7e40d508a8e733257aadb diff --git a/includes/watcheditem/WatchedItemStore.php b/includes/watcheditem/WatchedItemStore.php index 35e824e036..6b0c2aab11 100644 --- a/includes/watcheditem/WatchedItemStore.php +++ b/includes/watcheditem/WatchedItemStore.php @@ -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 @@ -693,7 +698,7 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac } // Update process cache to ensure skin doesn't claim that the current // page is unwatched in the response of action=watch itself (T28292). - // This would otherwise be re-queried from a slave by isWatched(). + // This would otherwise be re-queried from a replica by isWatched(). foreach ( $items as $item ) { $this->cache( $item ); } @@ -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 );