X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fsearch%2FSearchEngine.php;h=0a4b7c56d143c4b45d269466dea01e09abf75e33;hb=8a9f0e54f5ba0d7061c970228c5eec4004980896;hp=9a5126639b1ed3bdcb58bc6f4ab676b3e49717fd;hpb=73c78be11e87bc31542b6c1ddde775b2a1c9a791;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 9a5126639b..0a4b7c56d1 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -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,7 +121,7 @@ class SearchEngine { $allSearchTerms = array_merge( $allSearchTerms, $wgContLang->autoConvertToAllVariants( $searchterm ) ); } - $titleResult = ''; + $titleResult = null; if ( !wfRunHooks( 'SearchGetNearMatchBefore', array( $allSearchTerms, &$titleResult ) ) ) { return $titleResult; } @@ -383,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 );