* @ingroup FileAbstraction
*/
class ForeignAPIFile extends File {
+ /** @var bool */
private $mExists;
+ /** @var array */
+ private $mInfo = [];
protected $repoClass = 'ForeignApiRepo';
* @return ForeignAPIFile|null
*/
static function newFromTitle( Title $title, $repo ) {
- $data = $repo->fetchImageQuery( array(
+ $data = $repo->fetchImageQuery( [
'titles' => 'File:' . $title->getDBkey(),
'iiprop' => self::getProps(),
'prop' => 'imageinfo',
// extmetadata is language-dependant, accessing the current language here
// would be problematic, so we just get them all
'iiextmetadatamultilang' => 1,
- ) );
+ ] );
$info = $repo->getImageInfo( $data );
if ( !is_array( $metadata ) ) {
return $metadata;
}
- $ret = array();
+ $ret = [];
foreach ( $metadata as $meta ) {
$ret[$meta['name']] = self::parseMetadata( $meta['value'] );
}
if ( isset( $this->mInfo['descriptionshorturl'] ) ) {
return $this->mInfo['descriptionshorturl'];
} elseif ( isset( $this->mInfo['pageid'] ) ) {
- $url = $this->repo->makeUrl( array( 'curid' => $this->mInfo['pageid'] ) );
+ $url = $this->repo->makeUrl( [ 'curid' => $this->mInfo['pageid'] ] );
if ( $url !== false ) {
return $url;
}
public function getUser( $type = 'text' ) {
if ( $type == 'text' ) {
return isset( $this->mInfo['user'] ) ? strval( $this->mInfo['user'] ) : null;
- } elseif ( $type == 'id' ) {
+ } else {
return 0; // What makes sense here, for a remote user?
}
}
*/
function getMimeType() {
if ( !isset( $this->mInfo['mime'] ) ) {
- $magic = MimeMagic::singleton();
+ $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
$this->mInfo['mime'] = $magic->guessTypesForExtension( $this->getExtension() );
}
if ( isset( $this->mInfo['mediatype'] ) ) {
return $this->mInfo['mediatype'];
}
- $magic = MimeMagic::singleton();
+ $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
return $magic->getMediaType( null, $this->getMimeType() );
}
*/
function getThumbnails() {
$dir = $this->getThumbPath( $this->getName() );
- $iter = $this->repo->getBackend()->getFileList( array( 'dir' => $dir ) );
+ $iter = $this->repo->getBackend()->getFileList( [ 'dir' => $dir ] );
- $files = array();
+ $files = [];
foreach ( $iter as $file ) {
$files[] = $file;
}
return $files;
}
- /**
- * @see File::purgeCache()
- */
- function purgeCache( $options = array() ) {
+ function purgeCache( $options = [] ) {
$this->purgeThumbnails( $options );
$this->purgeDescriptionPage();
}
/**
* @param array $options
*/
- function purgeThumbnails( $options = array() ) {
+ function purgeThumbnails( $options = [] ) {
$key = $this->repo->getLocalCacheKey( 'ForeignAPIRepo', 'ThumbUrl', $this->getName() );
ObjectCache::getMainWANInstance()->delete( $key );
}
$dir = $this->getThumbPath( $this->getName() );
- $purgeList = array();
+ $purgeList = [];
foreach ( $files as $file ) {
$purgeList[] = "{$dir}{$file}";
}