X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Ffilerepo%2Ffile%2FFile.php;h=4e79de2d56109f20c0fe5aa09f3128bab912b4dd;hb=0d7137099ae137e7502374c502bcd0f1054db0aa;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..4e79de2d56 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -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' ) + ); } }