From f90c0659a9170dc2eeb0bc05768125224de850cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 11 Sep 2015 20:49:36 +0200 Subject: [PATCH] UploadBase: Return 'was-deleted' warning in addition to 'exists-normalized', not instead of The 'was-deleted' warning was generated by getExistsWarning(), which was returning immediately if this was found to be the case. A bunch of later checks were incorrectly skipped, in particular 'exists-normalized', which was resulting in UploadWizard incorrectly ignoring that problem. I'm not sure why that was part of getExistsWarning() at all, it doesn't seem very relevant. For that matter, neither do the 'thumb', 'thumb-name' and 'bad-prefix' warnings that it also generates, but this should not be a problem in practice and so I'm leaving them alone. Other than by allowing some more warning types to appear together or in different order, this should not affect action=upload API output or Special:Upload (which was updated appropriately). It does affect 'action=query&prop=imageinfo' output's 'html' property (used for AJAX checks on Special:Upload), which no longer includes the 'was-deleted' warning; this was never specified anywhere and just a side-effect. Bug: T48741 Change-Id: I3686ee8ffd635f5f06f51971b6f16e3e66f33a9e --- RELEASE-NOTES-1.27 | 2 ++ includes/specials/SpecialUpload.php | 28 ++++++++++++++-------------- includes/upload/UploadBase.php | 8 ++++---- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27 index 06feb4d139..e4793b336a 100644 --- a/RELEASE-NOTES-1.27 +++ b/RELEASE-NOTES-1.27 @@ -52,6 +52,8 @@ production. * ApiPageSet::setRedirectMergePolicy() was added. This allows generator modules to define how generator data for a redirect source gets merged into the redirect destination. +* prop=imageinfo&iiprop=uploadwarning will no longer include the possibility of + "was-deleted" warning. === Action API internal changes in 1.27 === diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 10d55b28bc..ad4407690d 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -263,7 +263,7 @@ class SpecialUpload extends SpecialPage { } # Give a notice if the user is uploading a file that has been deleted or moved - # Note that this is independent from the message 'filewasdeleted' that requires JS + # Note that this is independent from the message 'filewasdeleted' $desiredTitleObj = Title::makeTitleSafe( NS_FILE, $this->mDesiredDestName ); $delNotice = ''; // empty by default if ( $desiredTitleObj instanceof Title && !$desiredTitleObj->exists() ) { @@ -366,6 +366,19 @@ class SpecialUpload extends SpecialPage { } if ( $warning == 'exists' ) { $msg = "\t
  • " . self::getExistsWarning( $args ) . "
  • \n"; + } elseif ( $warning == 'was-deleted' ) { + # If the file existed before and was deleted, warn the user of this + $ltitle = SpecialPage::getTitleFor( 'Log' ); + $llink = Linker::linkKnown( + $ltitle, + wfMessage( 'deletionlog' )->escaped(), + array(), + array( + 'type' => 'delete', + 'page' => Title::makeTitle( NS_FILE, $args )->getPrefixedText(), + ) + ); + $msg = "\t
  • " . wfMessage( 'filewasdeleted' )->rawParams( $llink )->parse() . "
  • \n"; } elseif ( $warning == 'duplicate' ) { $msg = $this->getDupeWarning( $args ); } elseif ( $warning == 'duplicate-archive' ) { @@ -711,19 +724,6 @@ class SpecialUpload extends SpecialPage { $warning = wfMessage( 'file-thumbnail-no', $badPart )->parse(); } elseif ( $exists['warning'] == 'bad-prefix' ) { $warning = wfMessage( 'filename-bad-prefix', $exists['prefix'] )->parse(); - } elseif ( $exists['warning'] == 'was-deleted' ) { - # If the file existed before and was deleted, warn the user of this - $ltitle = SpecialPage::getTitleFor( 'Log' ); - $llink = Linker::linkKnown( - $ltitle, - wfMessage( 'deletionlog' )->escaped(), - array(), - array( - 'type' => 'delete', - 'page' => $filename - ) - ); - $warning = wfMessage( 'filewasdeleted' )->rawParams( $llink )->parseAsBlock(); } return $warning; diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 5193a7f423..8514187ea6 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -643,6 +643,10 @@ abstract class UploadBase { $warnings['exists'] = $exists; } + if ( $localFile->wasDeleted() && !$localFile->exists() ) { + $warnings['was-deleted'] = $filename; + } + // Check dupes against existing files $hash = $this->getTempFileSha1Base36(); $dupes = RepoGroup::singleton()->findBySha1( $hash ); @@ -1745,10 +1749,6 @@ abstract class UploadBase { return array( 'warning' => 'page-exists', 'file' => $file ); } - if ( $file->wasDeleted() && !$file->exists() ) { - return array( 'warning' => 'was-deleted', 'file' => $file ); - } - if ( strpos( $file->getName(), '.' ) == false ) { $partname = $file->getName(); $extension = ''; -- 2.20.1