From: Matthias Mullie Date: Thu, 5 Jan 2017 15:31:06 +0000 (+0100) Subject: Don't execute upload.loadConfig when it may not exist X-Git-Tag: 1.31.0-rc.0~4365 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=a71a52f916cdbe2ed559ff0081451ce72e0de4a3;p=lhc%2Fweb%2Fwiklou.git Don't execute upload.loadConfig when it may not exist Upload.BookletLayout creates a mw.Upload object, which has no loadConfig method. ForeignStructuredUpload.BookletLayout, which is a child of Upload.BookletLayout, creates a mw.ForeignStructuredUpload object, which does have this method. Thus, that method should be moved to where we know the object will have it. Change-Id: Ibb1c0f2b8260a8b0a7cc9f02e3434aed7d163637 --- diff --git a/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.BookletLayout.js b/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.BookletLayout.js index a5cf1d85c2..543ece881d 100644 --- a/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.BookletLayout.js +++ b/resources/src/mediawiki/mediawiki.ForeignStructuredUpload.BookletLayout.js @@ -107,6 +107,9 @@ e.stopPropagation(); } ); } ); + }, function ( errorMsg ) { + booklet.getPage( 'upload' ).$element.msg( errorMsg ); + return $.Deferred().resolve(); } ) ); } diff --git a/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js b/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js index c7ebfd8a51..f736036ecf 100644 --- a/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js +++ b/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js @@ -176,16 +176,9 @@ return this.upload.getApi().then( function ( api ) { - return $.when( - 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 the user can't upload anything, don't give them the option to. + return api.getUserInfo().then( + function ( userInfo ) { if ( userInfo.rights.indexOf( 'upload' ) === -1 ) { if ( mw.user.isAnon() ) { booklet.getPage( 'upload' ).$element.msg( 'api-error-mustbeloggedin' ); @@ -194,9 +187,7 @@ } } return $.Deferred().resolve(); - } ) - ).then( - null, + }, // Always resolve, never reject function () { return $.Deferred().resolve(); } );