Instruct stashed upload failures to reupload file
authorMatthias Mullie <git@mullie.eu>
Mon, 17 Jul 2017 14:23:32 +0000 (16:23 +0200)
committerMatthias Mullie <git@mullie.eu>
Wed, 30 Aug 2017 13:45:56 +0000 (15:45 +0200)
Given enough permissions, anonymous users can upload files
just fine. But when there are warnings, their failes can't
be stashed.
This is handled correctly by adding the <input type="file">
back to the form, but that could easily be overlooked:
- if you're used to being logged in and having your upload stashed
- the instructions only mention changing the description

This will slightly alter the instructions in such case so
that users are directed to re-upload their file when it
couldn't be stashed.

Bug: T115822
Change-Id: I81f5b112d158fe5f8b0850654af07d248bc3fda5

includes/specials/SpecialUpload.php
languages/i18n/en.json
languages/i18n/qqq.json

index 4cdc78f..fe16b90 100644 (file)
@@ -345,15 +345,16 @@ class SpecialUpload extends SpecialPage {
                $stashStatus = $this->mUpload->tryStashFile( $this->getUser() );
                if ( $stashStatus->isGood() ) {
                        $sessionKey = $stashStatus->getValue()->getFileKey();
+                       $uploadWarning = 'upload-tryagain';
                } else {
                        $sessionKey = null;
-                       // TODO Add a warning message about the failure to stash here?
+                       $uploadWarning = 'upload-tryagain-nostash';
                }
                $message = '<h2>' . $this->msg( 'uploaderror' )->escaped() . "</h2>\n" .
                        '<div class="error">' . $message . "</div>\n";
 
                $form = $this->getUploadForm( $message, $sessionKey );
-               $form->setSubmitText( $this->msg( 'upload-tryagain' )->escaped() );
+               $form->setSubmitText( $this->msg( $uploadWarning )->escaped() );
                $this->showUploadForm( $form );
        }
 
@@ -380,9 +381,10 @@ class SpecialUpload extends SpecialPage {
                $stashStatus = $this->mUpload->tryStashFile( $this->getUser() );
                if ( $stashStatus->isGood() ) {
                        $sessionKey = $stashStatus->getValue()->getFileKey();
+                       $uploadWarning = 'uploadwarning-text';
                } else {
                        $sessionKey = null;
-                       // TODO Add a warning message about the failure to stash here?
+                       $uploadWarning = 'uploadwarning-text-nostash';
                }
 
                // Add styles for the warning, reused from the live preview
@@ -444,7 +446,7 @@ class SpecialUpload extends SpecialPage {
                        $warningHtml .= $msg;
                }
                $warningHtml .= "</ul></div>\n";
-               $warningHtml .= $this->msg( 'uploadwarning-text' )->parseAsBlock();
+               $warningHtml .= $this->msg( $uploadWarning )->parseAsBlock();
 
                $form = $this->getUploadForm( $warningHtml, $sessionKey, /* $hideIgnoreWarning */ true );
                $form->setSubmitText( $this->msg( 'upload-tryagain' )->text() );
index a44b3cf..1b832ab 100644 (file)
        "uploadbtn": "Upload file",
        "reuploaddesc": "Cancel upload and return to the upload form",
        "upload-tryagain": "Submit modified file description",
+       "upload-tryagain-nostash": "Submit re-uploaded file and modified description",
        "uploadnologin": "Not logged in",
        "uploadnologintext": "Please $1 to upload files.",
        "upload_directory_missing": "The upload directory ($1) is missing and could not be created by the webserver.",
        "file-deleted-duplicate-notitle": "A file identical to this file has previously been deleted, and the title has been suppressed.\nYou should ask someone with the ability to view suppressed file data to review the situation before proceeding to re-upload it.",
        "uploadwarning": "Upload warning",
        "uploadwarning-text": "Please modify the file description below and try again.",
+       "uploadwarning-text-nostash": "Please re-upload the file, modify the description below and try again.",
        "savefile": "Save file",
        "uploadedimage": "uploaded \"[[$1]]\"",
        "overwroteimage": "uploaded a new version of \"[[$1]]\"",
index fb05de8..96ae965 100644 (file)
        "uploadbtn": "Button name in [[Special:Upload]].\n\nSee also:\n* {{msg-mw|Uploadbtn}}\n* {{msg-mw|Accesskey-upload}}\n* {{msg-mw|Tooltip-upload}}\n{{Identical|Upload file}}",
        "reuploaddesc": "Used as button text in the Upload form on [[Special:Upload]].\n\nSee also:\n* {{msg-mw|upload-tryagain|Submit button text}}\n* {{msg-mw|ignorewarning|button text}}",
        "upload-tryagain": "Used as Submit button text in [[Special:Upload]].\n\nSee also:\n* {{msg-mw|Uploaderror|section header}}\n* {{msg-mw|ignorewarning|button text}}\n* {{msg-mw|reuploaddesc|button text}}",
+       "upload-tryagain-nostash": "Used as Submit button text in [[Special:Upload]] when the upload could not be stashed & the file needs to be reuploaded.\n\nSee also:\n* {{msg-mw|Uploaderror|section header}}\n* {{msg-mw|ignorewarning|button text}}\n* {{msg-mw|reuploaddesc|button text}}",
        "uploadnologin": "Used as title of the error message {{msg-mw|Uploadnologintext}}.\n{{Identical|Not logged in}}",
        "uploadnologintext": "Used as error message.\n\nThe title for this message is {{msg-mw|Uploadnologin}}.\n\nParameters:\n* $1 - link text {{msg-mw|Loginreqlink}}. The link points to [[Special:UserLogin]].\nSee also:\n* {{msg-mw|Whitelistedittext}}\n* {{msg-mw|Nocreatetext}}\n* {{msg-mw|Loginreqpagetext}}",
        "upload_directory_missing": "Parameters:\n* $1 - directory name",
        "file-deleted-duplicate-notitle": "Used in [[Special:Upload]] when the title of the deleted duplicate is not available.\n\nSee also:\n* {{msg-mw|file-deleted-duplicate}}",
        "uploadwarning": "Used as section header in [[Special:Upload]].",
        "uploadwarning-text": "Used in [[Special:Upload]].",
+       "uploadwarning-text-nostash": "Used in [[Special:Upload]], when the upload could not be stashed & the file needs to be reuploaded.",
        "savefile": "When uploading a file",
        "uploadedimage": "{{ignored}}This is a ''logentry'' message only used on IRC. $1 is the name of the file uploaded.",
        "overwroteimage": "{{ignored}}This is a ''logentry'' message only used on IRC. $1 is the name of the file uploaded.",