X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FWatchedItemStore.php;h=cc4779ef38636b12950688a9b62b0f78cd61bb2b;hb=27f9e4af03792461027f7a4aa14f6f9b1cce972f;hp=90d45ce49c22c9444e6c930662432006911c4df8;hpb=5335a84c9ef221d03f264834cf136d9dd11a749a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WatchedItemStore.php b/includes/WatchedItemStore.php index 90d45ce49c..cc4779ef38 100644 --- a/includes/WatchedItemStore.php +++ b/includes/WatchedItemStore.php @@ -3,6 +3,7 @@ use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface; use MediaWiki\Linker\LinkTarget; use Wikimedia\Assert\Assert; +use Wikimedia\ScopedCallback; /** * Storage layer class for WatchedItems. @@ -166,7 +167,7 @@ class WatchedItemStore implements StatsdAwareInterface { * @param User $user * @param LinkTarget $target * - * @return WatchedItem|null + * @return WatchedItem|false */ private function getCached( User $user, LinkTarget $target ) { return $this->cache->get( $this->getCacheKey( $user, $target ) ); @@ -494,7 +495,7 @@ class WatchedItemStore implements StatsdAwareInterface { $watchedItems = []; foreach ( $res as $row ) { - // todo these could all be cached at some point? + // @todo: Should we add these to the process cache? $watchedItems[] = new WatchedItem( $user, new TitleValue( (int)$row->wl_namespace, $row->wl_title ), @@ -601,6 +602,7 @@ class WatchedItemStore implements StatsdAwareInterface { } $rows = []; + $items = []; foreach ( $targets as $target ) { $rows[] = [ 'wl_user' => $user->getId(), @@ -608,6 +610,11 @@ class WatchedItemStore implements StatsdAwareInterface { 'wl_title' => $target->getDBkey(), 'wl_notificationtimestamp' => null, ]; + $items[] = new WatchedItem( + $user, + $target, + null + ); $this->uncache( $user, $target ); } @@ -617,6 +624,12 @@ class WatchedItemStore implements StatsdAwareInterface { // if there's already an entry for this page $dbw->insert( 'watchlist', $toInsert, __METHOD__, 'IGNORE' ); } + // 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(). + foreach ( $items as $item ) { + $this->cache( $item ); + } return true; }