Merge "Unit tests: Remove duplicated code in ExtensionRegistry"
[lhc/web/wiklou.git] / includes / content / FileContentHandler.php
index 3028dfd..f3f9a97 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Content handler for File: files
  * TODO: this handler s not used directly now,
@@ -9,6 +11,7 @@
 class FileContentHandler extends WikitextContentHandler {
 
        public function getFieldsForSearchIndex( SearchEngine $engine ) {
+               $fields = [];
                $fields['file_media_type'] =
                        $engine->makeSearchFieldMapping( 'file_media_type', SearchIndexField::INDEX_TYPE_KEYWORD );
                $fields['file_media_type']->setFlag( SearchIndexField::FLAG_CASEFOLD );
@@ -41,7 +44,8 @@ class FileContentHandler extends WikitextContentHandler {
                if ( NS_FILE != $title->getNamespace() ) {
                        return [];
                }
-               $file = wfLocalFile( $title );
+               $file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
+                       ->newFile( $title );
                if ( !$file || !$file->exists() ) {
                        return [];
                }