From 4ff5bf253d93ac6b0820ad2ed9607e679426ec19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 27 Aug 2024 23:44:51 +0200 Subject: [PATCH] Reattempt the save when something already created a temporary account Bug: T368263 Change-Id: I2adcb83017daff578627aa02b04934be21eade44 --- modules/CommentController.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/CommentController.js b/modules/CommentController.js index baef4cecb..68d812449 100644 --- a/modules/CommentController.js +++ b/modules/CommentController.js @@ -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: [ {