Merge "Make determineCoreSchema a public function again in DatabasePostgres"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 29 Oct 2016 22:28:38 +0000 (22:28 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 29 Oct 2016 22:28:38 +0000 (22:28 +0000)
16 files changed:
includes/specialpage/PageQueryPage.php
includes/specialpage/QueryPage.php
includes/specialpage/WantedQueryPage.php
includes/specials/SpecialAncientpages.php
includes/specials/SpecialBrokenRedirects.php
includes/specials/SpecialLinkSearch.php
includes/specials/SpecialListDuplicatedFiles.php
includes/specials/SpecialMIMEsearch.php
includes/specials/SpecialMediaStatistics.php
includes/specials/SpecialMostcategories.php
includes/specials/SpecialMostinterwikis.php
includes/specials/SpecialMostlinked.php
includes/specials/SpecialMostlinkedcategories.php
includes/specials/SpecialMostlinkedtemplates.php
includes/specials/SpecialShortpages.php
includes/specials/SpecialUnusedcategories.php

index 97f004f..3bb3f85 100644 (file)
@@ -36,17 +36,7 @@ abstract class PageQueryPage extends QueryPage {
         * @param ResultWrapper $res
         */
        public function preprocessResults( $db, $res ) {
-               if ( !$res->numRows() ) {
-                       return;
-               }
-
-               $batch = new LinkBatch();
-               foreach ( $res as $row ) {
-                       $batch->add( $row->namespace, $row->title );
-               }
-               $batch->execute();
-
-               $res->seek( 0 );
+               $this->executeLBFromResultWrapper( $res );
        }
 
        /**
index afbc581..3592500 100644 (file)
@@ -825,4 +825,28 @@ abstract class QueryPage extends SpecialPage {
        function feedUrl() {
                return $this->getPageTitle()->getFullURL();
        }
+
+       /**
+        * Creates a new LinkBatch object, adds all pages from the passed ResultWrapper (MUST include
+        * title and optional the namespace field) and executes the batch. This operation will pre-cache
+        * LinkCache information like page existence and information for stub color and redirect hints.
+        *
+        * @param ResultWrapper $res The ResultWrapper object to process. Needs to include the title
+        *  field and namespace field, if the $ns parameter isn't set.
+        * @param null $ns Use this namespace for the given titles in the ResultWrapper object,
+        *  instead of the namespace value of $res.
+        */
+       protected function executeLBFromResultWrapper( ResultWrapper $res, $ns = null ) {
+               if ( !$res->numRows() ) {
+                       return;
+               }
+
+               $batch = new LinkBatch;
+               foreach ( $res as $row ) {
+                       $batch->add( $ns !== null ? $ns : $row->namespace, $row->title );
+               }
+               $batch->execute();
+
+               $res->seek( 0 );
+       }
 }
index 1c19f3c..39e3649 100644 (file)
@@ -41,18 +41,7 @@ abstract class WantedQueryPage extends QueryPage {
         * @param ResultWrapper $res
         */
        function preprocessResults( $db, $res ) {
-               if ( !$res->numRows() ) {
-                       return;
-               }
-
-               $batch = new LinkBatch;
-               foreach ( $res as $row ) {
-                       $batch->add( $row->namespace, $row->title );
-               }
-               $batch->execute();
-
-               // Back to start for display
-               $res->seek( 0 );
+               $this->executeLBFromResultWrapper( $res );
        }
 
        /**
index 724435b..9ee1b75 100644 (file)
@@ -64,6 +64,10 @@ class AncientPagesPage extends QueryPage {
                return false;
        }
 
+       public function preprocessResults( $db, $res ) {
+               $this->executeLBFromResultWrapper( $res );
+       }
+
        /**
         * @param Skin $skin
         * @param object $result Result row
index b9b2051..1753396 100644 (file)
@@ -171,18 +171,7 @@ class BrokenRedirectsPage extends QueryPage {
         * @param ResultWrapper $res
         */
        function preprocessResults( $db, $res ) {
-               if ( !$res->numRows() ) {
-                       return;
-               }
-
-               $batch = new LinkBatch;
-               foreach ( $res as $row ) {
-                       $batch->add( $row->namespace, $row->title );
-               }
-               $batch->execute();
-
-               // Back to start for display
-               $res->seek( 0 );
+               $this->executeLBFromResultWrapper( $res );
        }
 
        protected function getGroupName() {
index 307d6c3..a2fa844 100644 (file)
@@ -225,16 +225,7 @@ class LinkSearchPage extends QueryPage {
         * @param ResultWrapper $res
         */
        function preprocessResults( $db, $res ) {
-               if ( $res->numRows() > 0 ) {
-                       $linkBatch = new LinkBatch();
-
-                       foreach ( $res as $row ) {
-                               $linkBatch->add( $row->namespace, $row->title );
-                       }
-
-                       $res->seek( 0 );
-                       $linkBatch->execute();
-               }
+               $this->executeLBFromResultWrapper( $res );
        }
 
        /**
index 49fa417..dbe5c2f 100644 (file)
@@ -75,16 +75,7 @@ class ListDuplicatedFilesPage extends QueryPage {
         * @param ResultWrapper $res
         */
        function preprocessResults( $db, $res ) {
-               if ( $res->numRows() > 0 ) {
-                       $linkBatch = new LinkBatch();
-
-                       foreach ( $res as $row ) {
-                               $linkBatch->add( $row->namespace, $row->title );
-                       }
-
-                       $res->seek( 0 );
-                       $linkBatch->execute();
-               }
+               $this->executeLBFromResultWrapper( $res );
        }
 
        /**
index 6093f83..1d02a4f 100644 (file)
@@ -199,6 +199,10 @@ class MIMEsearchPage extends QueryPage {
                return in_array( $type, $types );
        }
 
+       public function preprocessResults( $db, $res ) {
+               $this->executeLBFromResultWrapper( $res );
+       }
+
        protected function getGroupName() {
                return 'media';
        }
index ec87716..7683ad8 100644 (file)
@@ -353,6 +353,7 @@ class MediaStatisticsPage extends QueryPage {
         * @param ResultWrapper $res
         */
        public function preprocessResults( $dbr, $res ) {
+               $this->executeLBFromResultWrapper( $res );
                $this->totalCount = $this->totalBytes = 0;
                foreach ( $res as $row ) {
                        $mediaStats = $this->splitFakeTitle( $row->title );
index 06d21d5..015701d 100644 (file)
@@ -69,19 +69,7 @@ class MostcategoriesPage extends QueryPage {
         * @param ResultWrapper $res
         */
        function preprocessResults( $db, $res ) {
-               # There's no point doing a batch check if we aren't caching results;
-               # the page must exist for it to have been pulled out of the table
-               if ( !$this->isCached() || !$res->numRows() ) {
-                       return;
-               }
-
-               $batch = new LinkBatch();
-               foreach ( $res as $row ) {
-                       $batch->add( $row->namespace, $row->title );
-               }
-               $batch->execute();
-
-               $res->seek( 0 );
+               $this->executeLBFromResultWrapper( $res );
        }
 
        /**
index 8271d16..3e78352 100644 (file)
@@ -75,20 +75,7 @@ class MostinterwikisPage extends QueryPage {
         * @param ResultWrapper $res
         */
        function preprocessResults( $db, $res ) {
-               # There's no point doing a batch check if we aren't caching results;
-               # the page must exist for it to have been pulled out of the table
-               if ( !$this->isCached() || !$res->numRows() ) {
-                       return;
-               }
-
-               $batch = new LinkBatch;
-               foreach ( $res as $row ) {
-                       $batch->add( $row->namespace, $row->title );
-               }
-               $batch->execute();
-
-               // Back to start for display
-               $res->seek( 0 );
+               $this->executeLBFromResultWrapper( $res );
        }
 
        /**
index 3663647..01eb39e 100644 (file)
@@ -78,16 +78,7 @@ class MostlinkedPage extends QueryPage {
         * @param ResultWrapper $res
         */
        function preprocessResults( $db, $res ) {
-               if ( $res->numRows() > 0 ) {
-                       $linkBatch = new LinkBatch();
-
-                       foreach ( $res as $row ) {
-                               $linkBatch->add( $row->namespace, $row->title );
-                       }
-
-                       $res->seek( 0 );
-                       $linkBatch->execute();
-               }
+               $this->executeLBFromResultWrapper( $res );
        }
 
        /**
index 3ead08a..41678cb 100644 (file)
@@ -59,18 +59,7 @@ class MostlinkedCategoriesPage extends QueryPage {
         * @param ResultWrapper $res
         */
        function preprocessResults( $db, $res ) {
-               if ( !$res->numRows() ) {
-                       return;
-               }
-
-               $batch = new LinkBatch;
-               foreach ( $res as $row ) {
-                       $batch->add( NS_CATEGORY, $row->title );
-               }
-               $batch->execute();
-
-               // Back to start for display
-               $res->seek( 0 );
+               $this->executeLBFromResultWrapper( $res );
        }
 
        /**
index 950241f..7fcb9d8 100644 (file)
@@ -79,17 +79,7 @@ class MostlinkedTemplatesPage extends QueryPage {
         * @param ResultWrapper $res
         */
        public function preprocessResults( $db, $res ) {
-               if ( !$res->numRows() ) {
-                       return;
-               }
-
-               $batch = new LinkBatch();
-               foreach ( $res as $row ) {
-                       $batch->add( $row->namespace, $row->title );
-               }
-               $batch->execute();
-
-               $res->seek( 0 );
+               $this->executeLBFromResultWrapper( $res );
        }
 
        /**
index a76b511..a78b082 100644 (file)
@@ -71,19 +71,7 @@ class ShortPagesPage extends QueryPage {
         * @param ResultWrapper $res
         */
        function preprocessResults( $db, $res ) {
-               # There's no point doing a batch check if we aren't caching results;
-               # the page must exist for it to have been pulled out of the table
-               if ( !$this->isCached() || !$res->numRows() ) {
-                       return;
-               }
-
-               $batch = new LinkBatch();
-               foreach ( $res as $row ) {
-                       $batch->add( $row->namespace, $row->title );
-               }
-               $batch->execute();
-
-               $res->seek( 0 );
+               $this->executeLBFromResultWrapper( $res );
        }
 
        function sortDescending() {
index 45efaf3..88c0e21 100644 (file)
@@ -76,4 +76,8 @@ class UnusedCategoriesPage extends QueryPage {
        protected function getGroupName() {
                return 'maintenance';
        }
+
+       public function preprocessResults( $db, $res ) {
+               $this->executeLBFromResultWrapper( $res );
+       }
 }