There is considerable confusion about what "parent revision" and "base revision" means in EditPage, WikiPage, and PageUpdater.
Status Quo
EditPage:
- editRevId and getBaseRevision() return the latest current revision as known to the client. This can be used to detect edit conflicts.
- oldId is the revision the edit was based on. When editing based on an old revision, it's the old revision's ID.
- parentRevId and getParentRevId() - The documentation says The "parent" revision is the ancestor that should be recorded in this page's revision history. It is either the revision ID of the in-memory article content, or in the case of a 3-way merge in order to rebase across a recoverable edit conflict, the ID of the newer revision to which we have rebased this page. However, this value does not to be recorded or in fact be used for anything at all. The semantics as described matches the rev_parent_id, but there is no need for EditPage to track this or set it explicitly. WikiPage (resp PageUpdater) just do this automatically.
- A CAS check is performed based on rev_id, ensuring the that current revision did not change after it was compared against editRevId to detect an edit conflict.
- see also T58849: Edit conflict detection by timestamp should be deprecated for how editRevId and parentRevId where introduced.
WikiPage:
- $baseRevId of doEditContent: The revision ID this edit reverts to, if any. Not stored, but passed to some hooks. Doesn't seems to be used for anything by core, but some extensions, like TimedMediaHandler, use it to detect reverts.
- rev_parent_id field: The ID of the revision that was current immediately before an edit. Used to display size differences in the page history (compare T193690)
NewRevisionFromEditComplete hook:
- $baseID: this hook parameter contains the value of $baseRevId from WikiPage::doEditContent. It's also set to the previous revision ID by MovePage. So the itnended semantics is "ID of an earlier revision that is restored or repeated by the edit".
PageUpdater:
- parent revision: the revision that is current before the edit is performed. Used for CAS checks.
- baseRevisionId: the latest current revision as known to the client. This can be used to detect edit conflicts. However, it is currently called set by doEditContent() with WikiPage's semantics in mind, causing confusion. Should probably be renamed to revertsToRevisionId.
Proposed Solution
- Improve documentation (and field names?) in EditPage to avoid confusion with the concepts as used in WikiPage.
- Improve documentation and parameter name in WikiPage::doEditContent to specify semantics to by "ID of an earlier revision that is restored or repeated by the edit"".
- Change PageUpdater::hasEditConflict() to not be based on the revision provided by setBaseRevision, but take a parameter and check against that instead.
- Change name of PageUpdater::setBaseRevisionId() to setOriginalRevisionId().
- Remove parentRevId logic from EditPage. getParentRevId() could just always return the current revision, if needed for B/C. But it does not seem like anything calls this.