Page MenuHomePhabricator

EditResult's revert is not marked correctly when using undoafter param
Closed, ResolvedPublic

Description

As @Proc has pointed out to me on IRC, it seems EditResult's revert-related fields are not set correctly when using the undoafter URL parameter. Weirdly enough, if one tries to revert just one revision (so undoafter is set to be the second-to-last revision) it works fine. The problem only occurs when the undo spans multiple edits.

There's some strange magic going, I'll try to fix it ASAP.

Event Timeline

Alright, I'm really confused now. Let's break things down:

  • There is a class named McrUndoAction that seems to contain all the ingredients necessary to properly mark an edit as a revert with the undoafter param. It is, however, deprecated since 1.32 and only accessible through calls to index.php?action=mcrundo which is just... wat.
    • EditResult-related code in this class is a bit broken, but mostly functional. The undoafter param works, but the oldest reverted ID is set incorrectly. I will fix that later.
  • In case we call action=edit, for either index.php or api.php, the request is routed to EditPage and then WikiPage. WikiPage::doEditContent (which is deprecated BTW) receives the undid revision id through its $undidRevId param. That works fine only single edit undos.
  • In case we use action=edit with the undoafter param:
    • When the undo is done through index.php, EditPage "loses" the undo-related parameters entirely and nothing gets passed on to WikiPage::doEditContent, not even the top undid revision, which results in the edit not being marked as a revert.
    • If we do the same through api.php, EditPage passes on to WikiPage the top undid revision ID correctly, but not the undoafter param, as there is no way to do that. The edit is marked as a revert, though, which I guess is a partial success.
So…?

I can fix the McrUndoAction easily, but I have no clue what is the current grand plan regarding the EditPage class. Is it waiting for a large refactor? I just don't know where to start with it. EditPage is a tangled mess that scares me a bit.

Change 609227 had a related patch set uploaded (by Ostrzyciel; owner: Ostrzyciel):
[mediawiki/core@master] Handle undos in action=mcrundo properly

https://gerrit.wikimedia.org/r/c/mediawiki/core/ /609227

Change 609517 had a related patch set uploaded (by Ostrzyciel; owner: Ostrzyciel):
[mediawiki/core@master] WIP: EditPage: handle undoafter param properly

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

Change 609227 merged by jenkins-bot:
[mediawiki/core@master] Handle undos in action=mcrundo properly

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

Change 609517 merged by jenkins-bot:
[mediawiki/core@master] EditPage: handle undoafter param properly

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

Change 612493 had a related patch set uploaded (by Kosta Harlan; owner: Ostrzyciel):
[mediawiki/core@REL1_35] EditPage: handle undoafter param properly

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

Just a status update, the two relevant patches were merged into master and one of them is waiting for a backport to 1.35.

All issues should be resolved on master, I'll close this when the backport is finished.

Change 612493 merged by jenkins-bot:
[mediawiki/core@REL1_35] EditPage: handle undoafter param properly

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