r13941 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13940‎ | r13941 | r13942 >
Date:22:01, 29 April 2006
Author:robchurch
Status:old
Tags:
Comment:
(bug 5716) Warn when a user tries to upload a file which was previously deleted
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Image.php (modified) (history)
  • /trunk/phase3/includes/SpecialUpload.php (modified) (history)
  • /trunk/phase3/languages/Messages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialUpload.php
@@ -48,7 +48,7 @@
4949 return;
5050 }
5151
52 - $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning');
 52+ $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' );
5353 $this->mReUpload = $request->getCheck( 'wpReUpload' );
5454 $this->mUpload = $request->getCheck( 'wpUpload' );
5555
@@ -298,6 +298,16 @@
299299 $sk = $wgUser->getSkin();
300300 $dlink = $sk->makeKnownLinkObj( $nt );
301301 $warning .= '<li>'.wfMsgHtml( 'fileexists', $dlink ).'</li>';
 302+ } else {
 303+ # If the file existed before and was deleted, warn the user of this
 304+ # Don't bother doing so if the image exists now, however
 305+ $image = new Image( $nt );
 306+ if( $image->wasDeleted() ) {
 307+ $skin = $wgUser->getSkin();
 308+ $ltitle = Title::makeTitle( NS_SPECIAL, 'Log' );
 309+ $llink = $skin->makeKnownLinkObj( $ltitle, wfMsgHtml( 'deletionlog' ), 'type=delete&page=' . $nt->getPrefixedUrl() );
 310+ $warning .= wfOpenElement( 'li' ) . wfMsgHtml( 'filewasdeleted', $llink ) . wfCloseElement( 'li' );
 311+ }
302312 }
303313
304314 if( $warning != '' ) {
Index: trunk/phase3/includes/Image.php
@@ -1641,6 +1641,17 @@
16421642 function isLocal() {
16431643 return !$this->fromSharedDirectory;
16441644 }
 1645+
 1646+ /**
 1647+ * Was this image ever deleted from the wiki?
 1648+ *
 1649+ * @return bool
 1650+ */
 1651+ function wasDeleted() {
 1652+ $dbw =& wfGetDB( DB_MASTER );
 1653+ $del = $dbw->selectField( 'archive', 'COUNT(*) AS count', array( 'ar_namespace' => NS_IMAGE, 'ar_title' => $this->title->getDBkey() ), 'Image::wasDeleted' );
 1654+ return $del > 0;
 1655+ }
16451656
16461657 } //class
16471658
Index: trunk/phase3/RELEASE-NOTES
@@ -145,6 +145,7 @@
146146 * Rewrite reassignEdits script to be more efficient; support optional updates to
147147 recent changes table; add reporting and silent modes
148148 * Cleaned up formatNum usage in langfiles
 149+* (bug 5716) Warn when a user tries to upload a file which was previously deleted
149150
150151 == Compatibility ==
151152
Index: trunk/phase3/languages/Messages.php
@@ -864,6 +864,7 @@
865865 'uploadvirus' => 'The file contains a virus! Details: $1',
866866 'sourcefilename' => 'Source filename',
867867 'destfilename' => 'Destination filename',
 868+'filewasdeleted' => 'A file of this name has been previously uploaded and subsequently deleted. You should check the $1 before proceeding to upload it again.',
868869
869870 'license' => 'Licensing',
870871 'nolicense' => 'None selected',

Status & tagging log