Index: trunk/phase3/includes/specials/SpecialLinkSearch.php |
— | — | @@ -114,13 +114,13 @@ |
115 | 115 | /** |
116 | 116 | * Return an appropriately formatted LIKE query and the clause |
117 | 117 | */ |
118 | | - static function mungeQuery( $query , $prot ) { |
| 118 | + static function mungeQuery( $query, $prot, $dbr ) { |
119 | 119 | $field = 'el_index'; |
120 | | - $rv = LinkFilter::makeLike( $query , $prot ); |
| 120 | + $rv = LinkFilter::makeLikeArray( $query , $prot ); |
121 | 121 | if ( $rv === false ) { |
122 | 122 | // LinkFilter doesn't handle wildcard in IP, so we'll have to munge here. |
123 | 123 | 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() ); |
125 | 125 | $field = 'el_to'; |
126 | 126 | } |
127 | 127 | } |
— | — | @@ -143,20 +143,20 @@ |
144 | 144 | // strip everything past first wildcard, so that |
145 | 145 | // index-based-only lookup would be done |
146 | 146 | list( $this->mMungedQuery, $clause ) = self::mungeQuery( |
147 | | - $this->mQuery, $this->mProt ); |
| 147 | + $this->mQuery, $this->mProt, $dbr ); |
148 | 148 | if( $this->mMungedQuery === false ) |
149 | 149 | // Invalid query; return no results |
150 | 150 | return array( 'tables' => 'page', 'fields' => 'page_id', 'conds' => '0=1' ); |
151 | 151 | |
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 ); |
154 | 154 | $retval = array ( |
155 | 155 | 'tables' => array ( 'page', 'externallinks' ), |
156 | 156 | 'fields' => array ( 'page_namespace AS namespace', |
157 | 157 | 'page_title AS title', |
158 | 158 | 'el_index AS value', 'el_to AS url' ), |
159 | 159 | 'conds' => array ( 'page_id = el_from', |
160 | | - "$clause LIKE $encSearch" ), |
| 160 | + "$clause $like" ), |
161 | 161 | 'options' => array( 'USE INDEX' => $clause ) |
162 | 162 | ); |
163 | 163 | if ( isset( $this->mNs ) && !$wgMiserMode ) { |