r44242 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44241‎ | r44242 | r44243 >
Date:21:21, 4 December 2008
Author:demon
Status:ok
Tags:
Comment:
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 :)
Modified paths:
  • /trunk/phase3/includes/filerepo/ForeignAPIFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/ForeignAPIFile.php
@@ -7,15 +7,19 @@
88 * @ingroup FileRepo
99 */
1010 class ForeignAPIFile extends File {
11 - function __construct( $title, $repo, $info ) {
 11+
 12+ private $mExists;
 13+
 14+ function __construct( $title, $repo, $info, $exists = false ) {
1215 parent::__construct( $title, $repo );
1316 $this->mInfo = $info;
 17+ $this->mExists = $exists;
1418 }
1519
1620 static function newFromTitle( $title, $repo ) {
1721 $info = $repo->getImageInfo( $title );
1822 if( $info ) {
19 - return new ForeignAPIFile( $title, $repo, $info );
 23+ return new ForeignAPIFile( $title, $repo, $info, true );
2024 } else {
2125 return null;
2226 }
@@ -23,7 +27,7 @@
2428
2529 // Dummy functions...
2630 public function exists() {
27 - return true;
 31+ return $this->mExists;
2832 }
2933
3034 public function getPath() {

Status & tagging log