Currently, saving a change to an entity works something like this:
- Let r2 be the current revision of page Foo, and r1 an older revision.
- The client submits a change to Foo, with r1 as the base revision
- The API creates a ChangeOp to represent the modification
- The change op is validated and applied to r1, producing r1'
- r1' is diffed against r1, producing patch p
- p is applied to r2, producing r2'. If p does not apply cleanly, we have an edit conflict.
This procedure is rather wasteful and error prone. Alternatively, we should:
- Let r2 be the current revision of page Foo, and r1 an older revision.
- The client submits a change to Foo, with r1 as the base revision
- The API creates a ChangeOp to represent the modification
- The change op checks for conflicts, given both r1 and r2
- The change op is validated and applied to r2, producing r2'
Note that we should take care to make sure to supply the current revision ID we used for validation, r2, as the "$baseRevId" parameter of EntityStore::saveEntity, to avoid a race condition in case of concurrent edits.