Problem/Motivation
Display Builder can override the view display of a single content entity (entity_view_override). The override is stored in a ui_patterns_source field on the content entity, so it travels with the content revisions.
When the content type uses Content Moderation, the current publishing flow does not follow the content workflow:
- The builder route loads the default revision, not the latest one. On content with a pending draft, the editor builds against the published content, not the draft they are working on.
- Publishing an override writes the display to the default revision. On content with a pending draft, that creates a new published default revision from the published content: the pending draft's other field changes are no longer in the latest revision, and the display goes live without a moderation transition.
- On content whose default revision is not published,
Instance::publish()still stores the published timestamp and reports "Published", although nothing is live. - There is no way to apply a moderation transition from the builder, and the available transitions depend on the current user's permissions.
- A transition made on the content form does not refresh open builders.
This is both a workflow bypass and a potential data loss for pending draft revisions.
Steps to reproduce the current behavior
- Enable Content Moderation, create an editorial workflow, and apply it to a content type that has an override display enabled.
- Create and publish a node, then create a draft revision with a changed title.
- Open the override builder for that node and publish the display.
- Inspect the node revisions: the new default published revision carries the published title, not the draft title; the pending draft is no longer the latest revision; no transition was applied.
Proposed resolution
Scope: display_builder_entity_view / entity_view_override only. Config-based displays (page layouts, entity view displays, Views) are out of scope: Content Moderation does not moderate config entities, and those are deployed with config sync/staging.
- Working vs live copy. The buildable edits the content's latest revision (W) and keeps the live revision (L) separate.
getSources()is W,getPublishedSources()is L.Instancecompares its draft (D) with both:D = Lis Published,D = W != Lis Staged, everything else Unpublished. - The State island becomes the content state control. On moderated content, the Publish button is replaced by the transitions the current user may apply (
StateTransitionValidation::getValidTransitions()). The visible half runs the primary transition (a published target first, then a self-transition, then the first); the caret lists the other transitions, then Restore and Revert. A badge shows the current state, green when it is a published state, amber otherwise. - One save per transition. The transition writes the display and the new
moderation_statein the same content revision, so the content's other draft fields are preserved and the display cannot go live without the transition. The instance still does not gain a revision: publishing adds no step to the instance history. - No transition, no write. A moderated display refuses a publish without a transition. Content Moderation itself forbids updating a moderated entity for a user with no valid transition, so such a user cannot open the builder; the island's disabled "No moderation action" branch covers the remaining stale or permission-change cases.
- Revert never bypasses the workflow. Revert clears the override in the working revision. When the latest revision is live, it first applies the transition that creates a draft and clears the field in that same save. A content that never had an override stays un-overridden on later transitions.
- Automatic revision log. The content revision log names the transition and the builder steps applied since the last content write, capped at five messages, when the content entity supports revision logs.
- Status model.
PublicationStatusgainsStaged; SaveStatus reportsPublished/Staged/Saved; the/publishresponse carriesX-DB-Publication-Outcomeso the client can show the resulting state. - Instances panel. The current row's status dot distinguishes staged from unpublished, and follows the staged outcome of a transition.
- Out-of-builder changes. A content save outside the builder records an SSE change for the affected instance, so open builders refresh after a transition made on the content form, a migration or a script.
- No change for non-moderated displays. Page layouts, Views, entity view displays, patterns and non-moderated overrides keep the existing Publish / Restore / Revert behavior.
User interface changes
- State island: on moderated content, the Publish split button becomes a content-state transition split button with a state badge (green for a published state, amber otherwise).
- SaveStatus: new
Stagedstatus. - Instances panel: staged dot for the current row.
- Restore and Revert stay in the caret. Revert can use a draft transition when the latest revision is live.
API changes
- New
ModeratedDisplayInterface:isModerated(),getModerationEntity(),getModerationStateId(),getModerationStateLabel(),isModerationStatePublished(),isWorkingRevisionLive(),getModerationActions(),applyModerationTransition(). DisplayBuildableInterface::getPublishedSources(): arrayandgetPublishedTime(): ?int.PublishableInterface::publish(?string $transition_id = NULL): PublicationStatus(wasvoid),isStagedPresent(): bool, andrevert(?string $transition_id = NULL): bool.DisplayBuildableOverrideInterface::revertOverride(?string $transition_id = NULL): bool.PublicationStatus::Staged.DisplayBuildablePluginBaseprovides defaultgetPublishedSources()andgetPublishedTime()for existing buildables.- Implementers that do not extend
DisplayBuildablePluginBasemust add the new methods.
Data model changes
None: no schema, field or config change. Existing instances on moderated content may change publication status from Published to Staged or Unpublished; no migration is needed.
Testing
- Kernel:
ModerationPublishTestcovers the pending-draft protection, the refusal without a transition, Revert in a draft and on live content, the empty-override rule, the SSE relay and the node revision log. - Functional:
ModerationStateIslandTestcovers a publisher's transitions, a user with a single transition, and the Content Moderation 403 without any transition. - Existing page layout, Views and entity view display tests are unchanged.
| Comment | File | Size | Author |
|---|---|---|---|
| wechat_2026-11-08_115613_016.png | 16.35 KB | prince.wang |
Issue fork display_builder-3636153
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
prince.wangComment #4
prince.wangComment #5
csakiistvanComment #6
csakiistvan🧪 Fix works, needs tests — applied MR !552, rebuilt caches, and on an editorial-moderated article with a pending draft ran "Create New Draft" then "Publish" from /node/{nid}/display/full: the live revision stayed untouched until Publish, and the new published revision kept the draft title and the override. Setting back to Needs work only for test coverage.
Actual results
/node/{nid}/latestreturned 403.Code review
545d53d5, pipeline green.InstanceRowStatusUnitTest,InstancePublicationUnitTestandProfileIslandPluginFormAjaxTest; no test touches Content Moderation, so a test that keeps the pending draft through a transition is missing.Comment #7
prince.wangCover the default editorial workflow transitions tests : https://git.drupalcode.org/project/display_builder/-/merge_requests/552/...
Comment #8
csakiistvan@prince.wang thanks for the quick response
✅ Tests cover the fix — rebased MR !552 locally onto current 1.0.x and ran the new tests:
ModerationPublishTest(14 tests) andModerationStateIslandTest(3 tests) pass with the fix; on 1.0.x without it 14/14 and 2/3 fail. That resolves my earlier "needs tests" point; only the rebase below remains.Notes
components/save_status/save_status.jswith #3635809 (requestConfig?.path?.split('?')[0]vs. the addedxhr); keeping both lines resolves it, a rebase is needed before merge.Comment #9
csakiistvanComment #10
prince.wang@csakiistvan thanks for your review, rebase to 1.0.x
Comment #11
mogtofu33 commentedThanks a lot for the work and the issue here.
The pending-draft data loss is real and the tests are solid.
Before merging, I'd like feedback on the shape: this puts content moderation, an optional core module, into the generic contracts right before the RC1 freeze, where Layout Builder leaves it to content_moderation itself.
Could we fix only the pending draft for RC1, and move states and transitions to a display_builder_content_moderation submodule after 1.0?
Other opinions welcome. Set to @pdureau for feedback.
Comment #12
csakiistvan@mogtofu33 +1. Only the pending-draft fix in RC1, and move states/transitions to a
display_builder_content_moderationsubmodule after 1.0. I'll retest once the MR is narrowed down.Comment #13
prince.wangThe Moderation feature requires changes to some APIs; if its implementation is deferred until after the RC (Release Candidate) phase, we must ensure that compatible interfaces are reserved in advance.
Comment #14
pdureau commentedHi all,
I am currently focused on the rc1 scope, so I missed it this one. Thanks for addressing this topic.
This feature request is only about
entity_view_overridebuildable, so I am surprised about 2 things:modules/display_builder_entity_view/For example, the added
ModeratedDisplayInterface:ModerationInformationInterface,RevisionableInterface,StateTransitionValidationInterface...)? just dropping interface names here, but this is the ideaApiPublishingController::publish(),Instance::publish(), andStateButtons, but this may be something to challenge.A first step could be to move the logic from
ApiPublishingController::publish()andInstance::publish()toEntityViewOverride::publish()(with some changes toDisplayBuildableInterface::publish()if needed).What do you think about that?
Moving to a sub-module depending of
display_builder_entity_viewandcontent_moderationcould be a good idea, if we want to make this feature a deliberated opt-in, instead of usingmoduleExists('content_moderation')here and there.But can we try to simplify the proposal as much as possible first? We may need more visibility before taking such decision.