Page MenuHomePhabricator

Visual Editor causes edit conflicts with HotCat
Closed, DuplicatePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Go to any page (for example: [[:en:Special:Permalink/1182977617]]
  • Make a change with the Visual Editor
  • Publish the change
  • Click the "Add a new cateory" icon (i.e. "+") at the bottom
  • Add a category and try to save it.

What happens?:
You get an edit conflict:

This is an old revision of this page, as edited by RoySmith (talk | contribs | block) at 2023-11-01T14:39:39 (removed Category:Tests using HotCat rm test). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

What should have happened instead?:

  • It should save the category change

Event Timeline

VE doesn't refresh the page (and thus reload HotCat) after saving an edit – this means when HotCat retrieves the wgCurRevisionId, it'll be referencing the revision ID prior to the VE edit, causing an edit conflict.

From function getPage():

var url = conf.wgServer + conf.wgScriptPath + '/api.php?format=json&callback=HotCat.start&action=query&rawcontinue=&titles=' +
encodeURIComponent( conf.wgPageName ) +
'&prop=info%7Crevisions&rvprop=content%7Ctimestamp%7Cids&meta=siteinfo&rvlimit=1&rvstartid=' +
conf.wgCurRevisionId;

I'm not sure if this is an issue with VE (should the page be reloaded fully after saving an edit? probably not..), or with HotCat (why doesn't HotCat just get the latest revision ID and use that?)

I'm not sure if this is an issue with VE (should the page be reloaded fully after saving an edit? probably not..), or with HotCat (why doesn't HotCat just get the latest revision ID and use that?)

I'd say it's a bug in HotCat.

@Jdforrester-WMF why is this HotCat's fault? From the description above, it sounds like the value of wgCurRevisionId being returned is incorrect. Surely a tool like HotCat should be able to rely on that being set properly, no?

It's a bug in HotCat because VisualEditor does update wgCurRevisionId after it saves an edit. HotCat stores a copy of the values on pageload and never updates them, and so it doesn't notice this.

Note this from the top of HotCat's JS:

	// Don't use mw.config.get() as that takes a copy of the config, and so doesn't
	// account for values changing, e.g. wgCurRevisionId after a VE edit
	var
        conf = $.extend( {}, mw.config.values, {
            // when running on mobile domain - do not use wgServer.
            wgServer: window.location.host.indexOf('.m.') > -1 ?
                '//' + window.location.host : mw.config.get( 'wgServer' )
        } );

The comment indicates that it's aware of VE updating things, but might possibly be incredibly outdated in beliefs about how mw.config.get works, and the chosen approach of just copying all the values to its own conf object causes this current bug.