Page MenuHomePhabricator

With VisualEditor enabled, when you navigate revisions, the address bar URL bounces back
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce:

  1. Go to https://ru.wikipedia.org/w/index.php?title=Иванов,_Валентин_Дмитриевич&diff=116003785&oldid=116003248&uselang=en while being logged on and having VisualEditor enabled.
  2. Expand RevisionSlider.
  3. Click "Older edit ←".

What happens?:

  1. The URL in the address bar changes to https://ru.wikipedia.org/w/index.php?diff=116003248&oldid=116002121&title=Иванов,_Валентин_Дмитриевич&uselang=en&diffmode=source.
  2. But then it reverts to https://ru.wikipedia.org/w/index.php?title=Иванов,_Валентин_Дмитриевич&diff=116003785&oldid=116003248&uselang=en&diffmode=source.
  3. As a result, if you refresh the page, you will see the original revision that you opened, not the one you navigated to.

What should have happened instead?:
The URL reversion shouldn't happen.

Why it happens?
I've debugged a bit, and the immediate reason of the reversion is this line of code: https://phabricator.wikimedia.org/diffusion/EVED/browse/master/modules/ve-mw/preinit/ve.init.mw.DiffPage.init.js$95.

history.replaceState( '', document.title, uri );

This code is part of the onReviewModeButtonSelectSelect function related to this button group:

image.png (48×208 px, 1 KB)

This happens only in wikis that have this button on diff pages (I guess this means VisualEditor enabled).

Event Timeline

This is also the reason why using the browser's "Back" button causes an issue. If you do everything I outlined in the "Steps to reproduce" section, then

  1. go to the table of contents,
  2. click some link in it,
  3. click "Back" in the browser,
  4. and then click "Newer edit →",

this will not work (you will stay with the same diff) and you will get https://ru.wikipedia.org/w/index.php?diff=NaN&oldid=NaN&title=Иванов,_Валентин_Дмитриевич&uselang=en&diffmode=source as the URL.

In case VisualEditor is to blame here I'll tag it too. (To be honest, that history.replaceState has always been annoying given that it altered the URL, adding diffmode= and making the URL longer, for no apparent reason.)

Since you've already debugged the issue, would you like to submit a patch to Gerrit? I'd be very happy to review and approve it. Looks like we just need to use a new mw.Uri object every time onReviewModeButtonSelectSelect() is called, to allow for other tools like RevisionSlider changing the page's URL, instead of always using the same object constructed on page load.

Also, this is probably the same issue as T260186.

would you like to submit a patch to Gerrit

OK, today or tomorrow.

Change 713039 had a related patch set uploaded (by Jack who built the house; author: Jack who built the house):

[mediawiki/extensions/VisualEditor@master] Fix history.replaceState call on diff pages

https://gerrit.wikimedia.org/r/713039

(These are in fact 2 thematically related changes that affect the same line of code, which is why I submitted them as a single patch. They can be split into two patches though if desirable.)

Change 713039 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Fix history.replaceState call on diff pages

https://gerrit.wikimedia.org/r/713039