X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Ffilerepo%2Ffile%2FForeignAPIFile.php;h=43b6855f825c21464beb0fa3ec20dc0345b413a8;hb=7874fc4bec845ad92960b07e969c65f3c3fe74f2;hp=43cb5a52320fa21e567eb2bdfbb96b499860c3d8;hpb=df622c4195cc5a9f1b9c2d4197e24f8b852c2861;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/file/ForeignAPIFile.php b/includes/filerepo/file/ForeignAPIFile.php index 43cb5a5232..43b6855f82 100644 --- a/includes/filerepo/file/ForeignAPIFile.php +++ b/includes/filerepo/file/ForeignAPIFile.php @@ -28,7 +28,10 @@ * @ingroup FileAbstraction */ class ForeignAPIFile extends File { + /** @var bool */ private $mExists; + /** @var array */ + private $mInfo = []; protected $repoClass = 'ForeignApiRepo'; @@ -53,7 +56,7 @@ class ForeignAPIFile extends File { * @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', @@ -61,7 +64,7 @@ class ForeignAPIFile extends File { // extmetadata is language-dependant, accessing the current language here // would be problematic, so we just get them all 'iiextmetadatamultilang' => 1, - ) ); + ] ); $info = $repo->getImageInfo( $data ); @@ -196,7 +199,7 @@ class ForeignAPIFile extends File { if ( !is_array( $metadata ) ) { return $metadata; } - $ret = array(); + $ret = []; foreach ( $metadata as $meta ) { $ret[$meta['name']] = self::parseMetadata( $meta['value'] ); } @@ -229,7 +232,7 @@ class ForeignAPIFile extends File { 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; } @@ -244,7 +247,7 @@ class ForeignAPIFile extends File { 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? } } @@ -334,9 +337,9 @@ class ForeignAPIFile extends File { */ 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; } @@ -344,10 +347,7 @@ class ForeignAPIFile extends File { return $files; } - /** - * @see File::purgeCache() - */ - function purgeCache( $options = array() ) { + function purgeCache( $options = [] ) { $this->purgeThumbnails( $options ); $this->purgeDescriptionPage(); } @@ -364,7 +364,7 @@ class ForeignAPIFile extends File { /** * @param array $options */ - function purgeThumbnails( $options = array() ) { + function purgeThumbnails( $options = [] ) { $key = $this->repo->getLocalCacheKey( 'ForeignAPIRepo', 'ThumbUrl', $this->getName() ); ObjectCache::getMainWANInstance()->delete( $key ); @@ -376,7 +376,7 @@ class ForeignAPIFile extends File { } $dir = $this->getThumbPath( $this->getName() ); - $purgeList = array(); + $purgeList = []; foreach ( $files as $file ) { $purgeList[] = "{$dir}{$file}"; }