Merge "ApiQueryRevisions: Fix error message key"
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index a520396..ed83aaf 100644 (file)
@@ -243,14 +243,12 @@ class SpecialSearch extends SpecialPage {
                        $this->namespaces = $nslist;
                } elseif ( $profile === 'advanced' ) {
                        $this->namespaces = $nslist;
+               } elseif ( isset( $profiles[$profile]['namespaces'] ) ) {
+                       $this->namespaces = $profiles[$profile]['namespaces'];
                } else {
-                       if ( isset( $profiles[$profile]['namespaces'] ) ) {
-                               $this->namespaces = $profiles[$profile]['namespaces'];
-                       } else {
-                               // Unknown profile requested
-                               $profile = 'default';
-                               $this->namespaces = $profiles['default']['namespaces'];
-                       }
+                       // Unknown profile requested
+                       $profile = 'default';
+                       $this->namespaces = $profiles['default']['namespaces'];
                }
 
                $this->fulltext = $request->getVal( 'fulltext' );
@@ -292,6 +290,7 @@ class SpecialSearch extends SpecialPage {
                }
 
                $out = $this->getOutput();
+               $widgetOptions = $this->getConfig()->get( 'SpecialSearchFormOptions' );
                $formWidget = new MediaWiki\Widget\Search\SearchFormWidget(
                        $this,
                        $this->searchConfig,
@@ -310,7 +309,7 @@ class SpecialSearch extends SpecialPage {
                        // only do the form render here for the empty $term case. Rendering
                        // the form when a search is provided is repeated below.
                        $out->addHTML( $formWidget->render(
-                               $this->profile, $term, 0, 0, $this->offset, $this->isPowerSearch()
+                               $this->profile, $term, 0, 0, $this->offset, $this->isPowerSearch(), $widgetOptions
                        ) );
                        return;
                }
@@ -332,13 +331,6 @@ class SpecialSearch extends SpecialPage {
                $showSuggestion = $title === null || !$title->isKnown();
                $search->setShowSuggestion( $showSuggestion );
 
-               $rewritten = $search->transformSearchTerm( $term );
-               if ( $rewritten !== $term ) {
-                       $term = $rewritten;
-                       wfDeprecated( 'SearchEngine::transformSearchTerm() (overridden by ' .
-                               get_class( $search ) . ')', '1.32' );
-               }
-
                $rewritten = $search->replacePrefixes( $term );
                if ( $rewritten !== $term ) {
                        wfDeprecated( 'SearchEngine::replacePrefixes() (overridden by ' .
@@ -374,7 +366,7 @@ class SpecialSearch extends SpecialPage {
                // start rendering the page
                $out->enableOOUI();
                $out->addHTML( $formWidget->render(
-                       $this->profile, $term, $num, $totalRes, $this->offset, $this->isPowerSearch()
+                       $this->profile, $term, $num, $totalRes, $this->offset, $this->isPowerSearch(), $widgetOptions
                ) );
 
                // did you mean... suggestions
@@ -656,7 +648,9 @@ class SpecialSearch extends SpecialPage {
                ) {
                        // Reset namespace preferences: namespaces are not searched
                        // when they're not mentioned in the URL parameters.
-                       foreach ( MWNamespace::getValidNamespaces() as $n ) {
+                       foreach ( MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces()
+                               as $n
+                       ) {
                                $user->setOption( 'searchNs' . $n, false );
                        }
                        // The request parameters include all the namespaces to be searched.