Merge "Perform a permission check on the title when changing the page language"
[lhc/web/wiklou.git] / includes / search / SearchNearMatcher.php
index bb7cd57..8e86865 100644 (file)
@@ -11,9 +11,15 @@ class SearchNearMatcher {
         */
        protected $config;
 
-       public function __construct( Config $config ) {
+       /**
+        * Current language
+        * @var Language
+        */
+       private $language;
 
+       public function __construct( Config $config, Language $lang ) {
                $this->config = $config;
+               $this->language = $lang;
        }
 
        /**
@@ -47,7 +53,7 @@ class SearchNearMatcher {
         * @return null|Title
         */
        protected function getNearMatchInternal( $searchterm ) {
-               $lang = $this->config->get( 'ContLang' );
+               $lang = $this->language;
 
                $allSearchTerms = [ $searchterm ];
 
@@ -64,7 +70,6 @@ class SearchNearMatcher {
                }
 
                foreach ( $allSearchTerms as $term ) {
-
                        # Exact match? No need to look further.
                        $title = Title::newFromText( $term );
                        if ( is_null( $title ) ) {