jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/333782 )
Change subject: mediawiki.api.options: Use sequential API requests in the remaining edge cases ...................................................................... mediawiki.api.options: Use sequential API requests in the remaining edge cases Bug: T100908 Change-Id: I927c098fd750bd765ffd746d40c3f7408f99f2de --- M resources/src/mediawiki/api/options.js 1 file changed, 25 insertions(+), 19 deletions(-) Approvals: Krinkle: Looks good to me, approved jenkins-bot: Verified diff --git a/resources/src/mediawiki/api/options.js b/resources/src/mediawiki/api/options.js index 069fbbf..4930c4f 100644 --- a/resources/src/mediawiki/api/options.js +++ b/resources/src/mediawiki/api/options.js @@ -26,7 +26,7 @@ * Any warnings returned by the API, including warnings about invalid option names or values, * are ignored. However, do not rely on this behavior. * - * If necessary, the options will be saved using several parallel API requests. Only one promise + * If necessary, the options will be saved using several sequential API requests. Only one promise * is always returned that will be resolved when all requests complete. * * @param {Object} options Options as a `{ name: value, … }` object @@ -35,7 +35,7 @@ saveOptions: function ( options ) { var name, value, bundleable, grouped = [], - deferreds = []; + promise = $.Deferred().resolve(); for ( name in options ) { value = options[ name ] === null ? null : String( options[ name ] ); @@ -58,32 +58,38 @@ } } else { if ( value !== null ) { - deferreds.push( this.postWithToken( 'csrf', { - formatversion: 2, - action: 'options', - optionname: name, - optionvalue: value - } ) ); + promise = promise.then( function ( name, value ) { + return this.postWithToken( 'csrf', { + formatversion: 2, + action: 'options', + optionname: name, + optionvalue: value + } ); + }.bind( this, name, value ) ); } else { // Omitting value resets the option - deferreds.push( this.postWithToken( 'csrf', { - formatversion: 2, - action: 'options', - optionname: name - } ) ); + promise = promise.then( function ( name ) { + return this.postWithToken( 'csrf', { + formatversion: 2, + action: 'options', + optionname: name + } ); + }.bind( this, name ) ); } } } if ( grouped.length ) { - deferreds.push( this.postWithToken( 'csrf', { - formatversion: 2, - action: 'options', - change: grouped - } ) ); + promise = promise.then( function () { + return this.postWithToken( 'csrf', { + formatversion: 2, + action: 'options', + change: grouped + } ); + }.bind( this ) ); } - return $.when.apply( $, deferreds ); + return promise; } } ); -- To view, visit https://gerrit.wikimedia.org/r/333782 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I927c098fd750bd765ffd746d40c3f7408f99f2de Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Anomie <bjor...@wikimedia.org> Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits