From: Chad Horohoe Date: Thu, 4 Dec 2008 21:21:48 +0000 (+0000) Subject: Actually make exists() useful here. Because of the order in which things are loaded... X-Git-Tag: 1.31.0-rc.0~44122 X-Git-Url: http://git.cyclocoop.org/clavettes/images/siteon3.jpg?a=commitdiff_plain;h=7b6bfe0c5d16e890984f5bd15ce7024e58f87c31;p=lhc%2Fweb%2Fwiklou.git 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 :) --- 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() {