Reattempt the save when something already created a temporary account

Bug: T368263
Change-Id: I2adcb83017daff578627aa02b04934be21eade44
This commit is contained in:
Bartosz Dziewoński 2024-08-27 23:44:51 +02:00
parent 5bb03b9e7f
commit 4ff5bf253d

View file

@ -586,6 +586,25 @@ CommentController.prototype.save = function ( pageName, extraParams ) {
return mw.libs.ve.targetSaver.postContent(
data, { api: noTimeoutApi }
).catch( ( code, responseData ) => {
if ( code === 'assertanonfailed' ) {
// Reattempt the save when something already created a temporary account (T368263)
return controller.getApi().get( {
meta: 'userinfo'
} ).then( ( resp ) => {
if ( !resp.query.userinfo.temp ) {
// Return the original error response
return $.Deferred().reject( code, responseData ).promise();
}
// Set new parameters and retry
data.assert = 'user';
data.assertuser = resp.query.userinfo.name;
return mw.libs.ve.targetSaver.postContent(
data, { api: noTimeoutApi }
);
} );
}
return $.Deferred().reject( code, responseData ).promise();
} ).catch( ( code, responseData ) => {
// Better user-facing error messages
if ( code === 'editconflict' ) {
return $.Deferred().reject( code, { errors: [ {