r24952 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24951‎ | r24952 | r24953 >
Date:14:49, 20 August 2007
Author:robchurch
Status:old
Tags:
Comment:
More robust existence/sanity checking
Modified paths:
  • /trunk/phase3/includes/FileDeleteForm.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/FileDeleteForm.php
@@ -10,6 +10,8 @@
1111
1212 private $title = null;
1313 private $file = null;
 14+
 15+ private $oldfile = null;
1416 private $oldimage = '';
1517
1618 /**
@@ -50,6 +52,8 @@
5153 $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars( $this->oldimage ) );
5254 return;
5355 }
 56+ if( $this->oldimage )
 57+ $this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->title, $this->oldimage );
5458
5559 if( !$this->haveDeletableFile() ) {
5660 $wgOut->addHtml( $this->prepareMessage( 'filedelete-nofile' ) );
@@ -57,14 +61,6 @@
5862 return;
5963 }
6064
61 - // Don't allow accidental deletion of a single file revision
62 - // if this is, in fact, the current revision; things might break
63 - if( $this->oldimage && $this->file->getTimestamp() == $this->getTimestamp() ) {
64 - $wgOut->addHtml( wfMsgExt( 'filedelete-iscurrent', 'parse' ) );
65 - $wgOut->addReturnTo( $this->title );
66 - return;
67 - }
68 -
6965 // Perform the deletion if appropriate
7066 if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->oldimage ) ) {
7167 $comment = $wgRequest->getText( 'wpComment' );
@@ -173,8 +169,9 @@
174170 * @return bool
175171 */
176172 private function haveDeletableFile() {
177 - $file = wfFindFile( $this->title, $this->oldimage );
178 - return $file && $file->exists() && $file->isLocal();
 173+ return $this->oldimage
 174+ ? $this->oldfile && $this->oldfile->exists() && $this->oldfile->isLocal()
 175+ : $this->file && $this->file->exists() && $this->file->isLocal();
179176 }
180177
181178 /**
@@ -196,12 +193,7 @@
197194 * @return string
198195 */
199196 private function getTimestamp() {
200 - static $timestamp = false;
201 - if( $timestamp === false ) {
202 - $file = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->title, $this->oldimage );
203 - $timestamp = $file->getTimestamp();
204 - }
205 - return $timestamp;
 197+ return $this->oldfile->getTimestamp();
206198 }
207199
208200 }
\ No newline at end of file
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1512,7 +1512,7 @@
15131513 'filedelete-success' => "'''$1''' has been deleted.",
15141514 'filedelete-success-old' => "<span class=\"plainlinks\">The version of '''[[Media:$1|$1]]''' as of $3, $2 has been deleted.</span>",
15151515 'filedelete-nofile' => "'''$1''' does not exist on this site.",
1516 -'filedelete-nofile-old' => "There is no version of '''$1''' dated $3, $2.",
 1516+'filedelete-nofile-old' => "There is no archived version of '''$1''' with the specified attributes.",
15171517 'filedelete-iscurrent' => 'You are attempting to delete the most recent version of this file. Please revert to an older version first.',
15181518
15191519 # MIME search

Follow-up revisions

RevisionCommit summaryAuthorDate
r25016Merged revisions 24866-25015 via svnmerge from...david23:06, 21 August 2007
r38618Remove unused message (since r24952).raymond09:50, 5 August 2008

Status & tagging log