X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Ffilerepo%2Ffile%2FFile.php;h=cfbd062a351ae6cec9b6cfcce9c3c62ba6a4547c;hb=7babd362babcbf7f20adb8e12edb4f4bc1d4249f;hp=32f4504ba6a124f7abbd41edcc5a36104fa0fda8;hpb=eca49eb5d2815d3a7b5375fe810d079dd3c17289;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index 32f4504ba6..cfbd062a35 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -148,7 +148,7 @@ abstract class File implements IDBAccessObject { protected $isSafeFile; /** @var string Required Repository class type */ - protected $repoClass = 'FileRepo'; + protected $repoClass = FileRepo::class; /** @var array Cache of tmp filepaths pointing to generated bucket thumbnails, keyed by width */ protected $tmpBucketedThumbCache = []; @@ -250,7 +250,7 @@ abstract class File implements IDBAccessObject { $oldMime = $old->getMimeType(); $n = strrpos( $new, '.' ); $newExt = self::normalizeExtension( $n ? substr( $new, $n + 1 ) : '' ); - $mimeMagic = MimeMagic::singleton(); + $mimeMagic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer(); return $mimeMagic->isMatchingExtension( $newExt, $oldMime ); } @@ -581,6 +581,25 @@ abstract class File implements IDBAccessObject { } } + /** + * Get the language code from the available languages for this file that matches the language + * requested by the user + * + * @param string $userPreferredLanguage + * @return string|null + */ + public function getMatchedLanguage( $userPreferredLanguage ) { + $handler = $this->getHandler(); + if ( $handler && method_exists( $handler, 'getMatchedLanguage' ) ) { + return $handler->getMatchedLanguage( + $userPreferredLanguage, + $handler->getAvailableLanguages( $this ) + ); + } else { + return null; + } + } + /** * In files that support multiple language, what is the default language * to use if none specified. @@ -1445,7 +1464,9 @@ abstract class File implements IDBAccessObject { // Purge cache of all pages using this file $title = $this->getTitle(); if ( $title ) { - DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'imagelinks' ) ); + DeferredUpdates::addUpdate( + new HTMLCacheUpdate( $title, 'imagelinks', 'file-purge' ) + ); } }