Problem/Motivation
When creating a content using layout builder in live and adding a block to the layout, then editing its layout in a workspace changing the block and saving its layout again, all is fine. Under normal circumstances, the node can now no longer be edited in the live workspace.
However, if say one changes the logic in EntityWorkspaceConflictConstraintValidator::validate() such that edits in a live are allowed again if there is a workspace revision, then re-editing the layout again in live will show the workspace revision of the block when editing the the layout and also the block.
The expected behavior would be to not show the very latest revision when re-editing in live but only the latest live revision instead.
Steps to reproduce
On Vanilla Drupal 11.1.x
- Enable wse_lb, workspaces_ui, layout_builder, media_library
- Comment the code in
EntityWorkspaceConflictConstraintValidator::validate() - Create a media (image bundle) reference field on the basic block bundle, use the media library widget
- Configure the article content type to use layout builder enabling Allow each content item to have its layout customized. option.
- Create an Article in live, customizing its layout and adding a basic block with an image media in it, save the layout
- Switch to the stage workspace to edit the layout, changing the image on the block, save the layout
- Switch back to live and edit the layout again
Expected result: Image from the live layout is displayed.
Actual result: Image from the stage layout is displayed.
Proposed resolution
Ensure the correct revision is loaded, possibly loading by block ID instead of revision ID as workspaces should automatically determine the correct revision and load that one.
Issue fork wse-3493965
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 #3
s_leu commentedComment #4
djdevinI had the same problem using https://www.drupal.org/project/workspaces_parallel/ but I fixed it in a way that worked for all content and not just inline blocks.
https://git.drupalcode.org/project/workspaces_parallel/-/blob/1.0.x/src/...
Layout builder is using getActiveMultiple() which will always load the latest revision, so I overrode that to return the latest revision in (or not in) a workspace.
Comment #5
danflanagan8Great comment, @djdevin.
Given that info, I wonder if this issue is fixed/duped by #3504057: The active variant of an entity in the Live workspace should be the default revision and/or #3541380: Node edit form always uses published revision when using content_moderation and workspaces
Comment #6
djdevinHmm I haven't tried it but the approach looks similar.
I sort of think this a duplicate of #3438083: Ability to edit content in Live while it’s also being edited in other workspaces which has the ability to re-enable live editing as described in the OP, and also fixes the issue with Layout Builder and other modules that might use getActive().
If we "fix" it here I don't think it could be tested since the editing is blocked.