Improved search backend fallback in Special:Search
authorReedy <reedy@wikimedia.org>
Tue, 10 Sep 2013 20:10:48 +0000 (21:10 +0100)
committerKevin Israel <pleasestand@live.com>
Tue, 10 Sep 2013 20:49:54 +0000 (16:49 -0400)
Use the srbackend parameter if it's valid.

If it's not, use $wgSearchType if it's not null.

Finally, fall back to the search type of the database.

Bug: 53982
Change-Id: I3605cb4add270543aa20afb037401b2dfbe462f0

includes/search/SearchEngine.php

index b691c75..e5925fa 100644 (file)
@@ -462,13 +462,16 @@ class SearchEngine {
                $dbr = null;
 
                $alternatives = self::getSearchTypes();
-               $type = $type !== null ? $type : $wgSearchType;
+
                if ( $type && in_array( $type, $alternatives ) ) {
                        $class = $type;
+               } elseif ( $wgSearchType !== null ) {
+                       $class = $wgSearchType;
                } else {
                        $dbr = wfGetDB( DB_SLAVE );
                        $class = $dbr->getSearchEngine();
                }
+
                $search = new $class( $dbr );
                $search->setLimitOffset( 0, 0 );
                return $search;