From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- includes/specials/SpecialLinkSearch.php | 52 ++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'includes/specials/SpecialLinkSearch.php') diff --git a/includes/specials/SpecialLinkSearch.php b/includes/specials/SpecialLinkSearch.php index 371469bb..75ff8f30 100644 --- a/includes/specials/SpecialLinkSearch.php +++ b/includes/specials/SpecialLinkSearch.php @@ -27,6 +27,8 @@ * @ingroup SpecialPage */ class LinkSearchPage extends QueryPage { + /** @var array|bool */ + private $mungedQuery = false; /** * @var PageLinkRenderer @@ -66,8 +68,9 @@ class LinkSearchPage extends QueryPage { * This allows for dependency injection even though we don't control object creation. */ private function initServices() { + global $wgLanguageCode; if ( !$this->linkRenderer ) { - $lang = $this->getContext()->getLanguage(); + $lang = Language::factory( $wgLanguageCode ); $titleFormatter = new MediaWikiTitleCodec( $lang, GenderCache::singleton() ); $this->linkRenderer = new MediaWikiPageLinkRenderer( $titleFormatter ); } @@ -88,7 +91,7 @@ class LinkSearchPage extends QueryPage { $request = $this->getRequest(); $target = $request->getVal( 'target', $par ); - $namespace = $request->getIntorNull( 'namespace', null ); + $namespace = $request->getIntOrNull( 'namespace', null ); $protocols_list = array(); foreach ( $this->getConfig()->get( 'UrlProtocols' ) as $prot ) { @@ -162,7 +165,7 @@ class LinkSearchPage extends QueryPage { 'namespace' => $namespace, 'protocol' => $protocol ) ); parent::execute( $par ); - if ( $this->mMungedQuery === false ) { + if ( $this->mungedQuery === false ) { $out->addWikiMsg( 'linksearch-error' ); } } @@ -221,13 +224,13 @@ class LinkSearchPage extends QueryPage { $dbr = wfGetDB( DB_SLAVE ); // strip everything past first wildcard, so that // index-based-only lookup would be done - list( $this->mMungedQuery, $clause ) = self::mungeQuery( $this->mQuery, $this->mProt ); - if ( $this->mMungedQuery === false ) { + list( $this->mungedQuery, $clause ) = self::mungeQuery( $this->mQuery, $this->mProt ); + if ( $this->mungedQuery === false ) { // Invalid query; return no results return array( 'tables' => 'page', 'fields' => 'page_id', 'conds' => '0=1' ); } - $stripped = LinkFilter::keepOneWildcard( $this->mMungedQuery ); + $stripped = LinkFilter::keepOneWildcard( $this->mungedQuery ); $like = $dbr->buildLike( $stripped ); $retval = array( 'tables' => array( 'page', 'externallinks' ), @@ -251,6 +254,25 @@ class LinkSearchPage extends QueryPage { return $retval; } + /** + * Pre-fill the link cache + * + * @param IDatabase $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 @@ -266,24 +288,6 @@ class LinkSearchPage extends QueryPage { return $this->msg( 'linksearch-line' )->rawParams( $urlLink, $pageLink )->escaped(); } - /** - * Override to check query validity. - * - * @param mixed $offset Numerical offset or false for no offset - * @param mixed $limit Numerical limit or false for no limit - */ - function doQuery( $offset = false, $limit = false ) { - list( $this->mMungedQuery, ) = LinkSearchPage::mungeQuery( $this->mQuery, $this->mProt ); - if ( $this->mMungedQuery === false ) { - $this->getOutput()->addWikiMsg( 'linksearch-error' ); - } else { - // For debugging - // Generates invalid xhtml with patterns that contain -- - //$this->getOutput()->addHTML( "\n\n" ); - parent::doQuery( $offset, $limit ); - } - } - /** * Override to squash the ORDER BY. * We do a truncated index search, so the optimizer won't trust -- cgit v1.2.3-54-g00ecf