jenkins-bot has submitted this change and it was merged.

Change subject: UploadBase: Return 'was-deleted' warning in addition to 
'exists-normalized', not instead of
......................................................................


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
---
M RELEASE-NOTES-1.27
M includes/specials/SpecialUpload.php
M includes/upload/UploadBase.php
3 files changed, 20 insertions(+), 18 deletions(-)

Approvals:
  Anomie: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27
index 06feb4d..e4793b3 100644
--- a/RELEASE-NOTES-1.27
+++ b/RELEASE-NOTES-1.27
@@ -52,6 +52,8 @@
 * 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 10d55b2..ad44076 100644
--- a/includes/specials/SpecialUpload.php
+++ b/includes/specials/SpecialUpload.php
@@ -263,7 +263,7 @@
                }
 
                # 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 @@
                        }
                        if ( $warning == 'exists' ) {
                                $msg = "\t<li>" . self::getExistsWarning( $args 
) . "</li>\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<li>" . wfMessage( 'filewasdeleted' 
)->rawParams( $llink )->parse() . "</li>\n";
                        } elseif ( $warning == 'duplicate' ) {
                                $msg = $this->getDupeWarning( $args );
                        } elseif ( $warning == 'duplicate-archive' ) {
@@ -711,19 +724,6 @@
                        $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 5193a7f..8514187 100644
--- a/includes/upload/UploadBase.php
+++ b/includes/upload/UploadBase.php
@@ -643,6 +643,10 @@
                        $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 );
@@ -1743,10 +1747,6 @@
 
                if ( $file->getTitle()->getArticleID() ) {
                        return array( 'warning' => 'page-exists', 'file' => 
$file );
-               }
-
-               if ( $file->wasDeleted() && !$file->exists() ) {
-                       return array( 'warning' => 'was-deleted', 'file' => 
$file );
                }
 
                if ( strpos( $file->getName(), '.' ) == false ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/237725
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3686ee8ffd635f5f06f51971b6f16e3e66f33a9e
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to