From 713f6e13a68fcc3f96ede4f755f3416d62fe3885 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 31 Dec 2010 16:44:31 +0000 Subject: [PATCH] Follow-up r78786: the querypage branch merge threw SpecialLinkSearch back to the pre-buildLike() era, so bring back makeLikeArray() and buildLike(). Also, fix an undefined $dbr in the old version. --- includes/specials/SpecialLinkSearch.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/specials/SpecialLinkSearch.php b/includes/specials/SpecialLinkSearch.php index f2fe3331bc..50a6242b15 100644 --- a/includes/specials/SpecialLinkSearch.php +++ b/includes/specials/SpecialLinkSearch.php @@ -114,13 +114,13 @@ class LinkSearchPage extends QueryPage { /** * Return an appropriately formatted LIKE query and the clause */ - static function mungeQuery( $query , $prot ) { + static function mungeQuery( $query, $prot, $dbr ) { $field = 'el_index'; - $rv = LinkFilter::makeLike( $query , $prot ); + $rv = LinkFilter::makeLikeArray( $query , $prot ); if ( $rv === false ) { // LinkFilter doesn't handle wildcard in IP, so we'll have to munge here. if (preg_match('/^(:?[0-9]{1,3}\.)+\*\s*$|^(:?[0-9]{1,3}\.){3}[0-9]{1,3}:[0-9]*\*\s*$/', $query)) { - $rv = $prot . rtrim($query, " \t*") . '%'; + $rv = array( $prot . rtrim( $query, " \t*" ), $dbr->anyString() ); $field = 'el_to'; } } @@ -143,20 +143,20 @@ class LinkSearchPage extends QueryPage { // strip everything past first wildcard, so that // index-based-only lookup would be done list( $this->mMungedQuery, $clause ) = self::mungeQuery( - $this->mQuery, $this->mProt ); + $this->mQuery, $this->mProt, $dbr ); if( $this->mMungedQuery === false ) // Invalid query; return no results return array( 'tables' => 'page', 'fields' => 'page_id', 'conds' => '0=1' ); - $stripped = substr( $this->mMungedQuery, 0, strpos( $this->mMungedQuery, '%' ) + 1 ); - $encSearch = $dbr->addQuotes( $stripped ); + $stripped = LinkFilter::keepOneWildcard( $this->mMungedQuery ); + $like = $dbr->buildLike( $stripped ); $retval = array ( 'tables' => array ( 'page', 'externallinks' ), 'fields' => array ( 'page_namespace AS namespace', 'page_title AS title', 'el_index AS value', 'el_to AS url' ), 'conds' => array ( 'page_id = el_from', - "$clause LIKE $encSearch" ), + "$clause $like" ), 'options' => array( 'USE INDEX' => $clause ) ); if ( isset( $this->mNs ) && !$wgMiserMode ) { -- 2.20.1