Followup r65114 (per CR cabal), remove SpecialSearchGomatch, replace with SpecialSear...
[lhc/web/wiklou.git] / includes / search / SearchEngine.php
index 635fbff..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;
        }
@@ -111,6 +121,7 @@ class SearchEngine {
                        $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 );