Followup r65114 (per CR cabal), remove SpecialSearchGomatch, replace with SpecialSear...
[lhc/web/wiklou.git] / includes / search / SearchEngine.php
index 3624f9e..0a4b7c5 100644 (file)
@@ -22,6 +22,14 @@ class SearchEngine {
        var $namespaces = array( NS_MAIN );
        var $showRedirects = false;
 
+       function __construct($db = null) {
+               if ( $db ) {
+                       $this->db = $db;
+               } else {
+                       $this->db = wfGetDB( DB_SLAVE );
+               }
+       }
+
        /**
         * Perform a full text search query and return a result set.
         * If title searches are not supported or disabled, return null.
@@ -84,6 +92,8 @@ class SearchEngine {
        public static function getNearMatch( $searchterm ) {
                $title = self::getNearMatchInternal( $searchterm );
 
+               wfRunHooks( 'SpecialSearchGomatch', array( &$title ) );
+
                wfRunHooks( 'SearchGetNearMatchComplete', array( $searchterm, &$title ) );
                return $title;
        }
@@ -108,9 +118,10 @@ class SearchEngine {
                $allSearchTerms = array( $searchterm );
 
                if ( $wgContLang->hasVariants() ) {
-                       $allSearchTerms = array_merge( $allSearchTerms, $wgContLang->convertLinkToAllVariants( $searchterm ) );
+                       $allSearchTerms = array_merge( $allSearchTerms, $wgContLang->autoConvertToAllVariants( $searchterm ) );
                }
 
+               $titleResult = null;
                if ( !wfRunHooks( 'SearchGetNearMatchBefore', array( $allSearchTerms, &$titleResult ) ) ) {
                        return $titleResult;
                }
@@ -382,10 +393,11 @@ class SearchEngine {
         */
        public static function create() {
                global $wgSearchType;
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = null;
                if ( $wgSearchType ) {
                        $class = $wgSearchType;
                } else {
+                       $dbr = wfGetDB( DB_SLAVE );
                        $class = $dbr->getSearchEngine();
                }
                $search = new $class( $dbr );
@@ -847,7 +859,7 @@ class SearchNearMatchResultSet extends SearchResultSet {
 class SearchHighlighter {
        var $mCleanWikitext = true;
 
-       function SearchHighlighter( $cleanupWikitext = true ) {
+       function __construct( $cleanupWikitext = true ) {
                $this->mCleanWikitext = $cleanupWikitext;
        }