Localisation updates from https://translatewiki.net.
[lhc/web/wiklou.git] / includes / api / ApiQueryInfo.php
index ea7818c..3aa0122 100644 (file)
@@ -453,10 +453,8 @@ class ApiQueryInfo extends ApiQueryBase {
                }
 
                if ( $this->fld_watchers ) {
-                       if ( isset( $this->watchers[$ns][$dbkey] ) ) {
+                       if ( $this->watchers[$ns][$dbkey] !== 0 || $this->showZeroWatchers ) {
                                $pageInfo['watchers'] = $this->watchers[$ns][$dbkey];
-                       } elseif ( $this->showZeroWatchers ) {
-                               $pageInfo['watchers'] = 0;
                        }
                }
 
@@ -799,28 +797,17 @@ class ApiQueryInfo extends ApiQueryBase {
                        return;
                }
 
-               $this->watchers = [];
                $this->showZeroWatchers = $canUnwatchedpages;
-               $db = $this->getDB();
-
-               $lb = new LinkBatch( $this->everything );
 
-               $this->resetQueryParams();
-               $this->addTables( [ 'watchlist' ] );
-               $this->addFields( [ 'wl_title', 'wl_namespace', 'count' => 'COUNT(*)' ] );
-               $this->addWhere( [
-                       $lb->constructSet( 'wl', $db )
-               ] );
-               $this->addOption( 'GROUP BY', [ 'wl_namespace', 'wl_title' ] );
+               $countOptions = [];
                if ( !$canUnwatchedpages ) {
-                       $this->addOption( 'HAVING', "COUNT(*) >= $unwatchedPageThreshold" );
+                       $countOptions['minimumWatchers'] = $unwatchedPageThreshold;
                }
 
-               $res = $this->select( __METHOD__ );
-
-               foreach ( $res as $row ) {
-                       $this->watchers[$row->wl_namespace][$row->wl_title] = (int)$row->count;
-               }
+               $this->watchers = WatchedItemStore::getDefaultInstance()->countWatchersMultiple(
+                       $this->everything,
+                       $countOptions
+               );
        }
 
        /**