Replies: 1 comment
|
#2483 makes sense to me for plugins that need to create a draft revision from collection content. I think there's one related case it may need to handle. Imagine a commerce plugin where products are normal EmDash collection entries:
Example: restoring an older product revision
Important If an editor restores Monday's collection revision, EmDash can restore the name to Hot Sauce, but the price stays $12 because it lives in plugin storage. That creates a product version that never actually existed: Monday's name combined with Friday's price. What should be restored together?I don't think the answer is to include all plugin storage in every revision. By Friday, the site may also have new stock counts, paid orders, and payment records. Restoring the product must not roll those back.
The plugin is responsible for telling EmDash which of its data is part of editing the product. EmDash would remain responsible for storing and restoring the complete revision safely. Question for EmDashWould you expect a plugin to be able to tell EmDash, "When this collection entry is revised or restored, include these specific pieces of plugin-owned data"? Or is the intended model that anything needing revisions must be a collection field or a plugin-declared collection, as discussed in #161? I'm asking what EmDash expects here, not proposing a specific API. The important behavior for me is that restoring one item should not restore only half of what the editor sees as that item. |
Uh oh!
There was an error while loading. Please reload this page.
Plugins that synchronize or import content need a safe way to propose changes without changing what readers currently see. Today,
ctx.content.updatechanges the live data columns; it does not give a plugin an editorial draft path for an already-published entry.Issue #2399 describes a related mismatch that can cause later publishing to overwrite those column changes. Fixing that data-loss behavior is important, but the goal here is narrower and additive: let a plugin deliberately create or advance a reviewable draft while the current published revision remains live.
Use cases
Proposal
A possible interface is:
Proposed contract:
patchinto the existing draft when one exists; otherwise use the live revision as the base.expectedDraftRevisionIdfor optimistic concurrency, so a plugin cannot silently overwrite an editor's newer draft.operationIdfor crash-safe replay. Scope it by plugin, collection, and entry so unrelated plugins or entries cannot collide.alreadyApplied: truewhen the same operation is replayed.I would avoid exposing an
operationRevisionIdunless Core needs it for a concrete caller contract. The draft revision ID and replay result seem sufficient for plugins.Simplest alternative
This may not need a new high-level method. It might be cleaner to fix or redefine
ctx.content.updateso updates consistently participate in revisions, or to expose a lower-level revision primitive that both admin and plugin paths share. Which seam would maintainers prefer?Non-goals
Suggested tests
expectedDraftRevisionIdis rejected.operationIdafter a simulated restart returns the original result without another revision.All reactions