mw.Upload.BookletLayout: Fail when unable to load config from foreign wiki
authorBartosz Dziewoński <matma.rex@gmail.com>
Wed, 8 Jun 2016 15:26:40 +0000 (17:26 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 8 Jun 2016 16:17:07 +0000 (18:17 +0200)
Previously we just ignored the problem and used the config from the local
wiki. This could result in incorrectly formatted uploads (if the error was
transient and the upload succeeded), or more confusing error messages
appearing later (if the error wasn't transient).

Change-Id: Ica6e65abbb678a9942c2bba6370e3ba156085bb8

languages/i18n/en.json
languages/i18n/qqq.json
resources/Resources.php
resources/src/mediawiki/mediawiki.ForeignStructuredUpload.js
resources/src/mediawiki/mediawiki.Upload.BookletLayout.js

index a028283..f808093 100644 (file)
        "upload-http-error": "An HTTP error occurred: $1",
        "upload-copy-upload-invalid-domain": "Copy uploads are not available from this domain.",
        "upload-foreign-cant-upload": "This wiki is not configured to upload files to the requested foreign file repository.",
+       "upload-foreign-cant-load-config": "Loading file upload configuration for the foreign file repository failed.",
        "upload-dialog-title": "Upload file",
        "upload-dialog-button-cancel": "Cancel",
        "upload-dialog-button-done": "Done",
index ad9a372..8c11752 100644 (file)
        "upload-http-error": "Parameters:\n* $1 - error message",
        "upload-copy-upload-invalid-domain": "Error message shown if a user is trying to upload (i.e. copy) a file from a website that is not in $wgCopyUploadsDomains (if set).\n\nSee also:\n* {{msg-mw|http-invalid-url}}\n* {{msg-mw|tmp-create-error}}\n* {{msg-mw|tmp-write-error}}",
        "upload-foreign-cant-upload": "Error message shown when a user is trying to upload a file to foreign repository that is not configured to receive file uploads from current wiki.",
+       "upload-foreign-cant-load-config": "Error message shown when a user is trying to upload a file to foreign repository and the foreign wiki is down or otherwise unable to respond to API requests.",
        "upload-dialog-title": "Title of the upload dialog box\n{{Identical|Upload file}}",
        "upload-dialog-button-cancel": "Button to cancel the dialog\n{{Identical|Cancel}}",
        "upload-dialog-button-done": "Button to close the dialog once upload is complete\n{{Identical|Done}}",
index b591b28..106a83b 100644 (file)
@@ -1195,6 +1195,9 @@ return [
                        'mediawiki.ForeignUpload',
                        'mediawiki.ForeignStructuredUpload.config',
                ],
+               'messages' => [
+                       'upload-foreign-cant-load-config',
+               ],
        ],
        'mediawiki.Upload.Dialog' => [
                'scripts' => [
index 4a0366a..c955729 100644 (file)
                                        // Foreign wiki might be running a pre-1.27 MediaWiki, without support for this
                                        if ( resp.query && resp.query.uploaddialog ) {
                                                upload.config = resp.query.uploaddialog;
+                                               return upload.config;
+                                       } else {
+                                               return $.Deferred().reject( 'upload-foreign-cant-load-config' );
                                        }
-                                       return upload.config;
+                               }, function () {
+                                       return $.Deferred().reject( 'upload-foreign-cant-load-config' );
                                } );
                        } );
                }
index 7a7469a..bbd0f1b 100644 (file)
                return this.upload.getApi().then(
                        function ( api ) {
                                return $.when(
-                                       booklet.upload.loadConfig(),
+                                       booklet.upload.loadConfig().then(
+                                               null,
+                                               function ( errorMsg ) {
+                                                       booklet.getPage( 'upload' ).$element.msg( errorMsg );
+                                                       return $.Deferred().resolve();
+                                               }
+                                       ),
                                        // If the user can't upload anything, don't give them the option to.
                                        api.getUserInfo().then( function ( userInfo ) {
                                                if ( userInfo.rights.indexOf( 'upload' ) === -1 ) {