Merge "Don't fallback from uk to ru"
[lhc/web/wiklou.git] / includes / specials / SpecialUnwatchedpages.php
index 4ad6ac0..ae375b2 100644 (file)
@@ -43,23 +43,44 @@ class UnwatchedpagesPage extends QueryPage {
                return false;
        }
 
+       /**
+        * Pre-cache page existence to speed up link generation
+        *
+        * @param IDatabase $db
+        * @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 );
+       }
+
        public function getQueryInfo() {
-               return array(
-                       'tables' => array( 'page', 'watchlist' ),
-                       'fields' => array(
+               $dbr = wfGetDB( DB_REPLICA );
+               return [
+                       'tables' => [ 'page', 'watchlist' ],
+                       'fields' => [
                                'namespace' => 'page_namespace',
                                'title' => 'page_title',
                                'value' => 'page_namespace'
-                       ),
-                       'conds' => array(
+                       ],
+                       'conds' => [
                                'wl_title IS NULL',
                                'page_is_redirect' => 0,
-                               "page_namespace != '" . NS_MEDIAWIKI . "'"
-                       ),
-                       'join_conds' => array( 'watchlist' => array(
-                               'LEFT JOIN', array( 'wl_title = page_title',
-                                       'wl_namespace = page_namespace' ) ) )
-               );
+                               'page_namespace != ' . $dbr->addQuotes( NS_MEDIAWIKI ),
+                       ],
+                       'join_conds' => [ 'watchlist' => [
+                               'LEFT JOIN', [ 'wl_title = page_title',
+                                       'wl_namespace = page_namespace' ] ] ]
+               ];
        }
 
        function sortDescending() {
@@ -67,7 +88,7 @@ class UnwatchedpagesPage extends QueryPage {
        }
 
        function getOrderFields() {
-               return array( 'page_namespace', 'page_title' );
+               return [ 'page_namespace', 'page_title' ];
        }
 
        /**
@@ -89,7 +110,7 @@ class UnwatchedpagesPage extends QueryPage {
 
                $nt = Title::makeTitleSafe( $result->namespace, $result->title );
                if ( !$nt ) {
-                       return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ),
+                       return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ],
                                Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
                }
 
@@ -99,8 +120,8 @@ class UnwatchedpagesPage extends QueryPage {
                $wlink = Linker::linkKnown(
                        $nt,
                        $this->msg( 'watch' )->escaped(),
-                       array( 'class' => 'mw-watch-link' ),
-                       array( 'action' => 'watch' )
+                       [ 'class' => 'mw-watch-link' ],
+                       [ 'action' => 'watch' ]
                );
 
                return $this->getLanguage()->specialList( $plink, $wlink );