Reduce calls to MediaWikiServices::getInstance()
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index 2cff90e..513d276 100644 (file)
@@ -269,8 +269,6 @@ class SpecialSearch extends SpecialPage {
         * @param string $term
         */
        public function showResults( $term ) {
-               global $wgContLang;
-
                if ( $this->searchEngineType !== null ) {
                        $this->setExtraParam( 'srbackend', $this->searchEngineType );
                }
@@ -281,7 +279,8 @@ class SpecialSearch extends SpecialPage {
                        $this->searchConfig,
                        $this->getSearchProfiles()
                );
-               $filePrefix = $wgContLang->getFormattedNsText( NS_FILE ) . ':';
+               $filePrefix = MediaWikiServices::getInstance()->getContentLanguage()->
+                       getFormattedNsText( NS_FILE ) . ':';
                if ( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
                        // Empty query -- straight view of search form
                        if ( !Hooks::run( 'SpecialSearchResultsPrepend', [ $this, $out, $term ] ) ) {
@@ -710,9 +709,10 @@ class SpecialSearch extends SpecialPage {
         */
        public function getSearchEngine() {
                if ( $this->searchEngine === null ) {
+                       $services = MediaWikiServices::getInstance();
                        $this->searchEngine = $this->searchEngineType ?
-                               MediaWikiServices::getInstance()->getSearchEngineFactory()->create( $this->searchEngineType ) :
-                               MediaWikiServices::getInstance()->newSearchEngine();
+                               $services->getSearchEngineFactory()->create( $this->searchEngineType ) :
+                               $services->newSearchEngine();
                }
 
                return $this->searchEngine;