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 = [];
$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 );
}
}
}
+ /**
+ * 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.
// 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' )
+ );
}
}