EditAttemptStep: Allow session ID override from query string or mw.config

Similar to WikiEditor, allow the editing_session_id value to be
overriden through the editingStatsId query parameter. Also allow
server-side code to override the session ID by setting
wgWMESchemaEditAttemptStepSessionId in mw.config.

Only apply the override to the first session. Once a second init event
happens, discard the overridden editing_session_id and generate a fresh
one.

Bug: T238249
Change-Id: I4ede70f310a35c95b6eb9cc34cfcf2baa77e69ee
This commit is contained in:
Roan Kattouw 2019-11-13 11:47:36 -08:00
parent 6caa4601aa
commit 0f97e1dce9

View file

@ -16,10 +16,16 @@
saveSuccess: 'save_success',
saveFailure: 'save_failure'
},
trackdebug = !!mw.Uri().query.trackdebug;
trackdebug = !!mw.Uri().query.trackdebug,
firstInitDone = false;
function getEditingSessionIdFromRequest() {
return mw.config.get( 'wgWMESchemaEditAttemptStepSessionId' ) ||
mw.Uri().query.editingStatsId;
}
timing = {};
editingSessionId = mw.user.generateRandomSessionId();
editingSessionId = getEditingSessionIdFromRequest() || mw.user.generateRandomSessionId();
function log() {
// mw.log is a no-op unless resource loader is in debug mode, so
@ -86,8 +92,11 @@
timeStamp = timeStamp || this.timeStamp; // I8e82acc12 back-compat
if ( action === 'init' ) {
// Regenerate editingSessionId
editingSessionId = mw.user.generateRandomSessionId();
if ( firstInitDone ) {
// Regenerate editingSessionId
editingSessionId = mw.user.generateRandomSessionId();
}
firstInitDone = true;
}
if ( !inSample() && !mw.config.get( 'wgWMESchemaEditAttemptStepOversample' ) && !trackdebug ) {