WatchedItemStore::countVisitingWatchersMultiple() shouldn't query all titles when...
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 18 Sep 2018 16:01:32 +0000 (12:01 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Tue, 18 Sep 2018 16:01:32 +0000 (12:01 -0400)
If a caller gives an empty array for $targetsWithVisitThresholds, per
the documentation it should be expecting an empty array in return, not a
count of watchers for every title in the database.

Bug: T204729
Change-Id: I0f25fae301450d077bb30597281aaef0fba209d4

includes/watcheditem/WatchedItemStore.php

index 6e907de..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 );