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:

  1. 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.
  2. 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.
  3. On content whose default revision is not published, Instance::publish() still stores the published timestamp and reports "Published", although nothing is live.
  4. There is no way to apply a moderation transition from the builder, and the available transitions depend on the current user's permissions.
  5. 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

  1. Enable Content Moderation, create an editorial workflow, and apply it to a content type that has an override display enabled.
  2. Create and publish a node, then create a draft revision with a changed title.
  3. Open the override builder for that node and publish the display.
  4. 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. Instance compares its draft (D) with both: D = L is Published, D = W != L is 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_state in 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. PublicationStatus gains Staged; SaveStatus reports Published / Staged / Saved; the /publish response carries X-DB-Publication-Outcome so 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 Staged status.
  • 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(): array and getPublishedTime(): ?int.
  • PublishableInterface::publish(?string $transition_id = NULL): PublicationStatus (was void), isStagedPresent(): bool, and revert(?string $transition_id = NULL): bool.
  • DisplayBuildableOverrideInterface::revertOverride(?string $transition_id = NULL): bool.
  • PublicationStatus::Staged.
  • DisplayBuildablePluginBase provides default getPublishedSources() and getPublishedTime() for existing buildables.
  • Implementers that do not extend DisplayBuildablePluginBase must 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: ModerationPublishTest covers 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: ModerationStateIslandTest covers 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.
CommentFileSizeAuthor
wechat_2026-11-08_115613_016.png16.35 KBprince.wang
Command icon 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

prince.wang created an issue. See original summary.

prince.wang’s picture

Title: Entity view overrides Content Moderation support » Entity view overrides Content Moderation/Workflow support

prince.wang’s picture

Status: Active » Needs review
csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

Assigned: csakiistvan » Unassigned
Status: Needs review » Needs work

🧪 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
  • Before the fix, Publish created a new default revision with the published title; the pending draft was no longer the latest revision and /node/{nid}/latest returned 403.
  • After the fix, "Create New Draft" saved the display in a new draft revision with the revision log "Create New Draft using Display Builder. Changes: Attach Textfield to root; Update Textfield configuration".
  • "Publish" then created a published default revision with the draft title and the override.
Code review
  • MR !552 at 545d53d5, pipeline green.
  • Blocking: the MR changes only InstanceRowStatusUnitTest, InstancePublicationUnitTest and ProfileIslandPluginFormAjaxTest; no test touches Content Moderation, so a test that keeps the pending draft through a transition is missing.
prince.wang’s picture

Status: Needs work » Needs review

Cover the default editorial workflow transitions tests : https://git.drupalcode.org/project/display_builder/-/merge_requests/552/...

csakiistvan’s picture

@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) and ModerationStateIslandTest (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
  • The branch is 11 commits behind 1.0.x and conflicts in components/save_status/save_status.js with #3635809 (requestConfig?.path?.split('?')[0] vs. the added xhr); keeping both lines resolves it, a rebase is needed before merge.
csakiistvan’s picture

Status: Needs review » Reviewed & tested by the community
prince.wang’s picture

@csakiistvan thanks for your review, rebase to 1.0.x

mogtofu33’s picture

Assigned: Unassigned » pdureau
Status: Reviewed & tested by the community » Needs review

Thanks 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.

csakiistvan’s picture

@mogtofu33 +1. Only the pending-draft fix in RC1, and move states/transitions to a display_builder_content_moderation submodule after 1.0. I'll retest once the MR is narrowed down.

prince.wang’s picture

The 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.

pdureau’s picture

Assigned: pdureau » Unassigned
Status: Needs review » Needs work

Hi 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_override buildable, so I am surprised about 2 things:

  • the volume of changes we need in total (+2500 lines)
  • the part of those changes which are outside modules/display_builder_entity_view/

For example, the added ModeratedDisplayInterface:

  • do we need those 7 new methods, knowing there are already related interfaces in Core (ModerationInformationInterface, RevisionableInterface, StateTransitionValidationInterface...)? just dropping interface names here, but this is the idea
  • why this interface lives in the main module? It is currently used by ApiPublishingController::publish(), Instance::publish(), and StateButtons, but this may be something to challenge.

A first step could be to move the logic from ApiPublishingController::publish() and Instance::publish() to EntityViewOverride::publish() (with some changes to DisplayBuildableInterface::publish() if needed).

What do you think about that?

Could we fix only the pending draft for RC1, and move states and transitions to a display_builder_content_moderation submodule after 1.0?

Moving to a sub-module depending of display_builder_entity_view and content_moderation could be a good idea, if we want to make this feature a deliberated opt-in, instead of using moduleExists('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.