When using the "undo" function to undo an edit (or a series of edits), changes to all slots should be undone, not just changes to the main slot.
This means that the logic for undoing edits needs to be extracted from EditPage.
At present, undo simply fails if multiple slots are involved, see T194412: Make undo fail gracefully for non-main slots..
Note that undo presently allows manual editing of the content to be undone. This is not possible for all kinds of content (see ContentHandler::supportsDirectEditing), and EditPage also does not currently support editing multiple slots at once.
It would probably be acceptable to not offer the ability to manually edit during an undo (check with product/UX), at least if the undo spans multiple slots. Or manual editing is only offered for the main slot - this seems ok for the SDC use case, but may be surprising when multiple slots are text based. We should at least show a warning explaining this.
Create an UndoAction that works for multiple slots, and functions be showing a diff, and a button to confirm the edit, with no editing ability. In Action::getActionName(), if $actionName === "edit", check if the page has multiple slots (a WikiPage is constructed towards the end of that method anyway). If it has multiple slots, set $actionName = 'undo', triggering the new code.
UndoAction may later gain editing ability, or may otherwise be consolidated with code that is being factored out of EditPage. For now, this approach allows us to implement undo logic that will work for SDC without touching the old behavior. Note that undo logic will have to be factored out of EditPage anyway at some point. This could act as a first step.
However: depending on how much of the logic in EditPage::internalAttemptSave needs to be replicated (especially, conflict resolution and various hook points, including edit filters), it may make more sense to at least have a partial refactoring of EditPage, to avoid duplicating this logic.
- Undo should not offer any free form editing ability for models for which ContentHandler::supportsDirectEditing returns false.
- Perhaps free form editing can be dropped from the undo function completely. If we keep it, we'll need T174033: Refactor EditPage to allow multiple slots to be edited atomically [MCR].
- A diff for each slot should be shown for confirmation, T194731: Show diffs for all slots [MCR].
- If undo supports editing, it needs to support preview! If it does not support editing, it could show a preview right away, T174036: Diffs page should show diffs and content from multiple slots [MCR].