Chad has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/141057

Change subject: Database search fixes:
......................................................................

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
---
M includes/deferred/SearchUpdate.php
M includes/search/SearchDatabase.php
M includes/search/SearchEngine.php
3 files changed, 14 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/57/141057/1

diff --git a/includes/deferred/SearchUpdate.php 
b/includes/deferred/SearchUpdate.php
index 9ae9034..20f348a 100644
--- a/includes/deferred/SearchUpdate.php
+++ b/includes/deferred/SearchUpdate.php
@@ -81,10 +81,10 @@
                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 @@
         *
         * @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 e3aafe8..82d0907 100644
--- a/includes/search/SearchDatabase.php
+++ b/includes/search/SearchDatabase.php
@@ -43,4 +43,15 @@
                        $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 3a3baef..d8c6f6d 100644
--- a/includes/search/SearchEngine.php
+++ b/includes/search/SearchEngine.php
@@ -420,17 +420,6 @@
        }
 
        /**
-        * 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.
         *

-- 
To view, visit https://gerrit.wikimedia.org/r/141057
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic2b830b56137b2dfe68b9b9c3de012151e716952
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Chad <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to