User:Daniel Kinzler (WMDE)/MCR-PageUpdater

This page describes how functionality related to WikiPage::doEditContent is to be refactored.

Situation on MW master, as per 2018-05-30

 * WikiPage::doEditContent is used to create new revisions of a page.
 * WikiPage::doEditUpdates can be used to force derived data to be updated, but it does not by itself re-parse the page.
 * WikiPage::prepareContentForEdit is used by hook handlers to access PST content and ParserOutput of edits-in-progress
 * EditPage is responsible for checking permissions, tokens, rate limits, etc. It also handles automatic conflict resolution (3-way-merge) and section edits.

Situation as per If610c68f49

 * PageHandler::saveRevision is used to create new revisions of a page. It still relies on WikiPage::insertOn and WikiPage::updateRevisionOn for updating the page table. It uses a DerivedPageDataUpdater to manage state while the edit is in progress, and for performing any updates of secondary or cached data.
 * DerivedPageDataUpdater::prepareContent essentially replaces WikiPage::prepareContentForEdit: it constructs PST content and (conceptually) provides parsed output (in reality, ParserOutput is constructed on demand, not immediately).
 * DerivedPageDataUpdater::prepareUpdate and DerivedPageDataUpdater::doUpdatesreplace WikiPage::doEditUpdates. Resources (especially, ParserOutput) generated by prepareContent is re-used when possible.

Conceptual Break-Down
Conceptually, we want to expose the following interfaces to application logic and extensions:


 * saveRevision(RevisionSlotsUpdate) aka doEditContent to create update a page by creating a new revision (or not, in case of a null-edit).
 * we may also want a version of saveRevision that directly takes a RevisionRecord, leaving PST to the caller.
 * edit for user-initiated edits, covering the functionality of EditPage abstracted from all UI code.
 * stashEdit for stashing pre-parsed content to be used by edit.
 * preview takes the same input as edit and returns rendered output for a new, unsaved revision.
 * Could make use of stashed output. Could also write into stash.
 * renderRevision takes a (saved?) RevisionRecord and returns output for it. Similar to preview. Used for plain views, history views, diff views, etc.

Further refactoring
TBD