Add LinkBatch to Special:LinkSearch
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 26 Sep 2014 18:47:42 +0000 (20:47 +0200)
committerUmherirrender <umherirrender_de.wp@web.de>
Thu, 30 Oct 2014 06:11:51 +0000 (06:11 +0000)
When building the result list, each link results in a database query.
The select is on the page table, so it is known, that each page exists,
but using Linker::linkKnown does not prepare the link for stubthreshold
or redirect marker.

Change-Id: I8f73d398f510f252ac8d5a0fd04ccb0feaf79cc4

includes/specials/SpecialLinkSearch.php

index 37edc0f..2d6213a 100644 (file)
@@ -251,6 +251,25 @@ class LinkSearchPage extends QueryPage {
                return $retval;
        }
 
+       /**
+        * Pre-fill the link cache
+        *
+        * @param DatabaseBase $db
+        * @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();
+               }
+       }
+
        /**
         * @param Skin $skin
         * @param object $result Result row