* @ingroup FileAbstraction
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Foreign file accessible through api.php requests.
* Very hacky and inefficient, do not use :D
/** @var array */
private $mInfo = [];
- protected $repoClass = ForeignApiRepo::class;
+ protected $repoClass = ForeignAPIRepo::class;
/**
* @param Title|string|bool $title
}
/**
- * @param array $metadata
- * @return array
+ * @param mixed $metadata
+ * @return mixed
*/
public static function parseMetadata( $metadata ) {
if ( !is_array( $metadata ) ) {
/**
* @param int $audience
- * @param User $user
+ * @param User|null $user
* @return null|string
*/
public function getDescription( $audience = self::FOR_PUBLIC, User $user = null ) {
}
/**
- * @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;
$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 );
}
/**
*/
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