diff options
author | Amir Sarabadani <ladsgroup@gmail.com> | 2022-01-12 12:39:41 +0100 |
---|---|---|
committer | Ladsgroup <Ladsgroup@gmail.com> | 2022-01-18 08:43:15 +0000 |
commit | af2a9be43bd8dad126524f3636371c2dd297503b (patch) | |
tree | 1f5b26adc26b99bf58bf6c968aa9036076538494 | |
parent | a99156d3d060086d0fb1af20d47f4092ee15b33d (diff) |
watcheditem: Try getting the cached version in resetNotificationTimestamp
loadWatchedItem() bypasses cache and because of that, now we have a
duplicate query to watchlist table in EVERY PAGE VIEW.
You can follow the code path in https://performance.wikimedia.org/xhgui/run/symbol?id=61d70085b6eef2185e6c1353&symbol=WatchedItemStore%3A%3AloadWatchedItem
Change-Id: I534a46bdc956bbefe1c5c9d2db82eabec3cbd5e6
(cherry picked from commit a3250bd942b9faa1145805f7867bee36cf85aceb)
-rw-r--r-- | includes/watcheditem/WatchedItemStore.php | 2 | ||||
-rw-r--r-- | tests/phpunit/unit/includes/watcheditem/WatchedItemStoreUnitTest.php | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/includes/watcheditem/WatchedItemStore.php b/includes/watcheditem/WatchedItemStore.php index 254123fc4e8b..885b92f48811 100644 --- a/includes/watcheditem/WatchedItemStore.php +++ b/includes/watcheditem/WatchedItemStore.php @@ -1430,7 +1430,7 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac $item = null; if ( $force != 'force' ) { - $item = $this->loadWatchedItem( $user, $title ); + $item = $this->getWatchedItem( $user, $title ); if ( !$item || $item->getNotificationTimestamp() === null ) { return false; } diff --git a/tests/phpunit/unit/includes/watcheditem/WatchedItemStoreUnitTest.php b/tests/phpunit/unit/includes/watcheditem/WatchedItemStoreUnitTest.php index 0f5d8a88fdeb..14a98364877d 100644 --- a/tests/phpunit/unit/includes/watcheditem/WatchedItemStoreUnitTest.php +++ b/tests/phpunit/unit/includes/watcheditem/WatchedItemStoreUnitTest.php @@ -2231,7 +2231,7 @@ class WatchedItemStoreUnitTest extends MediaWikiUnitTestCase { ->willReturn( [] ); $mockCache = $this->getMockCache(); - $mockCache->expects( $this->never() )->method( 'get' ); + $mockCache->expects( $this->once() )->method( 'get' ); $mockCache->expects( $this->never() )->method( 'set' ); $mockCache->expects( $this->never() )->method( 'delete' ); @@ -2287,7 +2287,7 @@ class WatchedItemStoreUnitTest extends MediaWikiUnitTestCase { ] ); $mockCache = $this->getMockCache(); - $mockCache->expects( $this->never() )->method( 'get' ); + $mockCache->expects( $this->once() )->method( 'get' ); $mockCache->expects( $this->once() ) ->method( 'set' ) ->with( @@ -2811,7 +2811,7 @@ class WatchedItemStoreUnitTest extends MediaWikiUnitTestCase { ] ); $mockCache = $this->getMockCache(); - $mockCache->expects( $this->never() )->method( 'get' ); + $mockCache->expects( $this->once() )->method( 'get' ); $mockCache->expects( $this->once() ) ->method( 'set' ) ->with( '0:SomeDbKey:1', $this->isType( 'object' ) ); |