r79347 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79346‎ | r79347 | r79348 >
Date:16:44, 31 December 2010
Author:catrope
Status:resolved
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialLinkSearch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialLinkSearch.php
@@ -114,13 +114,13 @@
115115 /**
116116 * Return an appropriately formatted LIKE query and the clause
117117 */
118 - static function mungeQuery( $query , $prot ) {
 118+ static function mungeQuery( $query, $prot, $dbr ) {
119119 $field = 'el_index';
120 - $rv = LinkFilter::makeLike( $query , $prot );
 120+ $rv = LinkFilter::makeLikeArray( $query , $prot );
121121 if ( $rv === false ) {
122122 // LinkFilter doesn't handle wildcard in IP, so we'll have to munge here.
123123 if (preg_match('/^(:?[0-9]{1,3}\.)+\*\s*$|^(:?[0-9]{1,3}\.){3}[0-9]{1,3}:[0-9]*\*\s*$/', $query)) {
124 - $rv = $prot . rtrim($query, " \t*") . '%';
 124+ $rv = array( $prot . rtrim( $query, " \t*" ), $dbr->anyString() );
125125 $field = 'el_to';
126126 }
127127 }
@@ -143,20 +143,20 @@
144144 // strip everything past first wildcard, so that
145145 // index-based-only lookup would be done
146146 list( $this->mMungedQuery, $clause ) = self::mungeQuery(
147 - $this->mQuery, $this->mProt );
 147+ $this->mQuery, $this->mProt, $dbr );
148148 if( $this->mMungedQuery === false )
149149 // Invalid query; return no results
150150 return array( 'tables' => 'page', 'fields' => 'page_id', 'conds' => '0=1' );
151151
152 - $stripped = substr( $this->mMungedQuery, 0, strpos( $this->mMungedQuery, '%' ) + 1 );
153 - $encSearch = $dbr->addQuotes( $stripped );
 152+ $stripped = LinkFilter::keepOneWildcard( $this->mMungedQuery );
 153+ $like = $dbr->buildLike( $stripped );
154154 $retval = array (
155155 'tables' => array ( 'page', 'externallinks' ),
156156 'fields' => array ( 'page_namespace AS namespace',
157157 'page_title AS title',
158158 'el_index AS value', 'el_to AS url' ),
159159 'conds' => array ( 'page_id = el_from',
160 - "$clause LIKE $encSearch" ),
 160+ "$clause $like" ),
161161 'options' => array( 'USE INDEX' => $clause )
162162 );
163163 if ( isset( $this->mNs ) && !$wgMiserMode ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r79350r79347 didn't update other callers to mungeQuery(), so let's just take the ea...catrope16:53, 31 December 2010
r793511.17: Fix fatal error due to undefined $dbr introduced in r57989. This was fi...catrope16:56, 31 December 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r78786Merge querypage-work2 branch from trunk. The most relevant changes are:...catrope14:16, 22 December 2010

Status & tagging log