private $title = null;
private $file = null;
+
+ private $oldfile = null;
private $oldimage = '';
/**
$wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars( $this->oldimage ) );
return;
}
+ if( $this->oldimage )
+ $this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->title, $this->oldimage );
if( !$this->haveDeletableFile() ) {
$wgOut->addHtml( $this->prepareMessage( 'filedelete-nofile' ) );
return;
}
- // Don't allow accidental deletion of a single file revision
- // if this is, in fact, the current revision; things might break
- if( $this->oldimage && $this->file->getTimestamp() == $this->getTimestamp() ) {
- $wgOut->addHtml( wfMsgExt( 'filedelete-iscurrent', 'parse' ) );
- $wgOut->addReturnTo( $this->title );
- return;
- }
-
// Perform the deletion if appropriate
if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->oldimage ) ) {
$comment = $wgRequest->getText( 'wpComment' );
* @return bool
*/
private function haveDeletableFile() {
- $file = wfFindFile( $this->title, $this->oldimage );
- return $file && $file->exists() && $file->isLocal();
+ return $this->oldimage
+ ? $this->oldfile && $this->oldfile->exists() && $this->oldfile->isLocal()
+ : $this->file && $this->file->exists() && $this->file->isLocal();
}
/**
* @return string
*/
private function getTimestamp() {
- static $timestamp = false;
- if( $timestamp === false ) {
- $file = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->title, $this->oldimage );
- $timestamp = $file->getTimestamp();
- }
- return $timestamp;
+ return $this->oldfile->getTimestamp();
}
}
\ No newline at end of file
'filedelete-success' => "'''$1''' has been deleted.",
'filedelete-success-old' => "<span class=\"plainlinks\">The version of '''[[Media:$1|$1]]''' as of $3, $2 has been deleted.</span>",
'filedelete-nofile' => "'''$1''' does not exist on this site.",
-'filedelete-nofile-old' => "There is no version of '''$1''' dated $3, $2.",
+'filedelete-nofile-old' => "There is no archived version of '''$1''' with the specified attributes.",
'filedelete-iscurrent' => 'You are attempting to delete the most recent version of this file. Please revert to an older version first.',
# MIME search