From 7b6bfe0c5d16e890984f5bd15ce7024e58f87c31 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 4 Dec 2008 21:21:48 +0000 Subject: [PATCH] Actually make exists() useful here. Because of the order in which things are loaded, we've actually _already_ loaded the metadata prior to calling the constructor. It's safe to assume when making a new ForeignAPIFile that we'll want it to exist at that point. However, we'll default to false as it's safer to assume it doesn't exist and skip ourselves some Http requests. You should probably only be using newFromTitle() anyway :) --- includes/filerepo/ForeignAPIFile.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/filerepo/ForeignAPIFile.php b/includes/filerepo/ForeignAPIFile.php index 847f9dc71d..fa692b15bb 100644 --- a/includes/filerepo/ForeignAPIFile.php +++ b/includes/filerepo/ForeignAPIFile.php @@ -7,15 +7,19 @@ * @ingroup FileRepo */ class ForeignAPIFile extends File { - function __construct( $title, $repo, $info ) { + + private $mExists; + + function __construct( $title, $repo, $info, $exists = false ) { parent::__construct( $title, $repo ); $this->mInfo = $info; + $this->mExists = $exists; } static function newFromTitle( $title, $repo ) { $info = $repo->getImageInfo( $title ); if( $info ) { - return new ForeignAPIFile( $title, $repo, $info ); + return new ForeignAPIFile( $title, $repo, $info, true ); } else { return null; } @@ -23,7 +27,7 @@ class ForeignAPIFile extends File { // Dummy functions... public function exists() { - return true; + return $this->mExists; } public function getPath() { -- 2.20.1