* Create a OldLocalFile from a SHA-1 key
* Do not call this except from inside a repo class.
*
- * @param string $sha1 base-36 SHA-1
+ * @param string $sha1 Base-36 SHA-1
* @param LocalRepo $repo
* @param string|bool $timestamp MW_timestamp (optional)
*
* @param Title $title
* @param FileRepo $repo
* @param string $time Timestamp or null to load by archive name
- * @param string $archiveName archive name or null to load by timestamp
+ * @param string $archiveName Archive name or null to load by timestamp
* @throws MWException
*/
function __construct( $title, $repo, $time, $archiveName ) {
}
function loadFromDB( $flags = 0 ) {
- wfProfileIn( __METHOD__ );
$this->dataLoaded = true;
$this->fileExists = false;
}
- wfProfileOut( __METHOD__ );
}
/**
* Load lazy file metadata from the DB
*/
protected function loadExtraFromDB() {
- wfProfileIn( __METHOD__ );
$this->extraDataLoaded = true;
$dbr = $this->repo->getSlaveDB();
$this->$name = $value;
}
} else {
- wfProfileOut( __METHOD__ );
throw new MWException( "Could not find data for image '{$this->archive_name}'." );
}
- wfProfileOut( __METHOD__ );
}
/**
}
function upgradeRow() {
- wfProfileIn( __METHOD__ );
$this->loadFromFile();
# Don't destroy file info of missing files
if ( !$this->fileExists ) {
wfDebug( __METHOD__ . ": file does not exist, aborting\n" );
- wfProfileOut( __METHOD__ );
return;
}
'oi_archive_name' => $this->archive_name ),
__METHOD__
);
- wfProfileOut( __METHOD__ );
}
/**
return true;
}
+
+ /**
+ * If archive name is an empty string, then file does not "exist"
+ *
+ * This is the case for a couple files on Wikimedia servers where
+ * the old version is "lost".
+ */
+ public function exists() {
+ $archiveName = $this->getArchiveName();
+ if ( $archiveName === '' || !is_string( $archiveName ) ) {
+ return false;
+ }
+ return parent::exists();
+ }
}