From: Chad Horohoe Date: Fri, 20 Jun 2014 20:43:36 +0000 (-0700) Subject: Database search fixes: X-Git-Tag: 1.31.0-rc.0~15288^2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=cd9dc7ef3f504e91b990cba0f3e97460937a2bcb;p=lhc%2Fweb%2Fwiklou.git Database search fixes: - Move filter() function and make it protected, nothing uses it outside database-backed searching - Use per-backend legal search characters rather than assuming the static implementation is right Change-Id: Ic2b830b56137b2dfe68b9b9c3de012151e716952 --- diff --git a/includes/deferred/SearchUpdate.php b/includes/deferred/SearchUpdate.php index 9ae903422a..20f348a213 100644 --- a/includes/deferred/SearchUpdate.php +++ b/includes/deferred/SearchUpdate.php @@ -81,10 +81,10 @@ class SearchUpdate implements DeferrableUpdate { wfProfileIn( __METHOD__ ); $page = WikiPage::newFromId( $this->id, WikiPage::READ_LATEST ); - $indexTitle = $this->indexTitle(); foreach ( SearchEngine::getSearchTypes() as $type ) { $search = SearchEngine::create( $type ); + $indexTitle = $this->indexTitle( $search ); if ( !$search->supports( 'search-update' ) ) { continue; } @@ -181,13 +181,13 @@ class SearchUpdate implements DeferrableUpdate { * * @return string A stripped-down title string ready for the search index */ - private function indexTitle() { + private function indexTitle( SearchEngine $search ) { global $wgContLang; $ns = $this->title->getNamespace(); $title = $this->title->getText(); - $lc = SearchEngine::legalSearchChars() . '&#;'; + $lc = $search->legalSearchChars() . '&#;'; $t = $wgContLang->normalizeForSearch( $title ); $t = preg_replace( "/[^{$lc}]+/", ' ', $t ); $t = $wgContLang->lc( $t ); diff --git a/includes/search/SearchDatabase.php b/includes/search/SearchDatabase.php index e3aafe8679..82d09073bc 100644 --- a/includes/search/SearchDatabase.php +++ b/includes/search/SearchDatabase.php @@ -43,4 +43,15 @@ class SearchDatabase extends SearchEngine { $this->db = wfGetDB( DB_SLAVE ); } } + + /** + * Return a 'cleaned up' search string + * + * @param string $text + * @return string + */ + protected function filter( $text ) { + $lc = $this->legalSearchChars(); + return trim( preg_replace( "/[^{$lc}]/", " ", $text ) ); + } } diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 3a3baef18c..d8c6f6d103 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -419,17 +419,6 @@ class SearchEngine { return $formatted; } - /** - * Return a 'cleaned up' search string - * - * @param string $text - * @return string - */ - function filter( $text ) { - $lc = $this->legalSearchChars(); - return trim( preg_replace( "/[^{$lc}]/", " ", $text ) ); - } - /** * Load up the appropriate search engine class for the currently * active database backend, and return a configured instance.