X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Ffilerepo%2Ffile%2FForeignAPIFile.php;h=8dcb289abd27a4a1f4f4f8041ed18521bb201807;hb=478a58f63101f2b47d18a618296b5e7970fa3f24;hp=43b6855f825c21464beb0fa3ec20dc0345b413a8;hpb=eb53a231a7ec3b5c8f42c056ba041b23ae181b1d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/file/ForeignAPIFile.php b/includes/filerepo/file/ForeignAPIFile.php index 43b6855f82..1002b82c52 100644 --- a/includes/filerepo/file/ForeignAPIFile.php +++ b/includes/filerepo/file/ForeignAPIFile.php @@ -21,6 +21,8 @@ * @ingroup FileAbstraction */ +use MediaWiki\MediaWikiServices; + /** * Foreign file accessible through api.php requests. * Very hacky and inefficient, do not use :D @@ -33,7 +35,7 @@ class ForeignAPIFile extends File { /** @var array */ private $mInfo = []; - protected $repoClass = 'ForeignApiRepo'; + protected $repoClass = ForeignAPIRepo::class; /** * @param Title|string|bool $title @@ -192,8 +194,8 @@ class ForeignAPIFile extends File { } /** - * @param array $metadata - * @return array + * @param mixed $metadata + * @return mixed */ public static function parseMetadata( $metadata ) { if ( !is_array( $metadata ) ) { @@ -254,7 +256,7 @@ class ForeignAPIFile extends File { /** * @param int $audience - * @param User $user + * @param User|null $user * @return null|string */ public function getDescription( $audience = self::FOR_PUBLIC, User $user = null ) { @@ -286,7 +288,7 @@ class ForeignAPIFile extends File { */ function getMimeType() { if ( !isset( $this->mInfo['mime'] ) ) { - $magic = MimeMagic::singleton(); + $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer(); $this->mInfo['mime'] = $magic->guessTypesForExtension( $this->getExtension() ); } @@ -300,7 +302,7 @@ class ForeignAPIFile extends File { if ( isset( $this->mInfo['mediatype'] ) ) { return $this->mInfo['mediatype']; } - $magic = MimeMagic::singleton(); + $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer(); return $magic->getMediaType( null, $this->getMimeType() ); } @@ -333,15 +335,17 @@ class ForeignAPIFile extends File { } /** - * @return array + * @return string[] */ function getThumbnails() { $dir = $this->getThumbPath( $this->getName() ); $iter = $this->repo->getBackend()->getFileList( [ 'dir' => $dir ] ); $files = []; - foreach ( $iter as $file ) { - $files[] = $file; + if ( $iter ) { + foreach ( $iter as $file ) { + $files[] = $file; + } } return $files; @@ -358,7 +362,7 @@ class ForeignAPIFile extends File { $url = $this->repo->getDescriptionRenderUrl( $this->getName(), $wgContLang->getCode() ); $key = $this->repo->getLocalCacheKey( 'RemoteFileDescription', 'url', md5( $url ) ); - ObjectCache::getMainWANInstance()->delete( $key ); + MediaWikiServices::getInstance()->getMainWANObjectCache()->delete( $key ); } /** @@ -366,7 +370,7 @@ class ForeignAPIFile extends File { */ function purgeThumbnails( $options = [] ) { $key = $this->repo->getLocalCacheKey( 'ForeignAPIRepo', 'ThumbUrl', $this->getName() ); - ObjectCache::getMainWANInstance()->delete( $key ); + MediaWikiServices::getInstance()->getMainWANObjectCache()->delete( $key ); $files = $this->getThumbnails(); // Give media handler a chance to filter the purge list