Fix for bug 33270: default to 'default' search profile
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Tue, 20 Dec 2011 11:17:36 +0000 (11:17 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Tue, 20 Dec 2011 11:17:36 +0000 (11:17 +0000)
Had this fixed in one of my wikies but not committed

includes/specials/SpecialSearch.php

index c2fac94..f884401 100644 (file)
@@ -117,15 +117,19 @@ class SpecialSearch extends SpecialPage {
                $user = $this->getUser();
                # Extract manually requested namespaces
                $nslist = $this->powerSearch( $request );
-               $this->profile = $profile = $request->getVal( 'profile', null );
+               $profile = null;
+               if ( !count( $nslist ) ) {
+                       $profile = 'default';
+               }
+               $profile = $request->getVal( 'profile', $profile );
                $profiles = $this->getSearchProfiles();
-               if ( $profile === null) {
+               if ( $profile === null ) {
                        // BC with old request format
-                       $this->profile = 'advanced';
+                       $profile = 'advanced';
                        if ( count( $nslist ) ) {
                                foreach( $profiles as $key => $data ) {
                                        if ( $nslist === $data['namespaces'] && $key !== 'advanced') {
-                                               $this->profile = $key;
+                                               $profile = $key;
                                        }
                                }
                                $this->namespaces = $nslist;
@@ -139,7 +143,7 @@ class SpecialSearch extends SpecialPage {
                                $this->namespaces = $profiles[$profile]['namespaces'];
                        } else {
                                // Unknown profile requested
-                               $this->profile = 'default';
+                               $profile = 'default';
                                $this->namespaces = $profiles['default']['namespaces'];
                        }
                }
@@ -149,6 +153,7 @@ class SpecialSearch extends SpecialPage {
                $this->searchRedirects = $request->getBool( 'redirs', $default ) ? 1 : 0;
                $this->didYouMeanHtml = ''; # html of did you mean... link
                $this->fulltext = $request->getVal('fulltext');
+               $this->profile = $profile;
        }
 
        /**