Problem/Motivation
Currently if a node has been edited in a non-live workspace, it cannot be edited in live.
If you go to the edit form, you see the following message:
The content is being edited in the Stage workspace. As a result, your changes cannot be saved.
This message comes from EntityWorkspaceConflictConstraint, which seems to be basically unchanged since #2784921: Add Workspaces experimental module.
A common use case for workspaces is to prepare a large number of changes ahead of a major change such as a product launch or rebrand.
If a node has been edited in a workspace for that reason, and there's an urgent change needed on one of those nodes, content editors are blocked from changing it in live.
Steps to reproduce
Proposed resolution
tbc - may depend on discussion in #2867707: WI: Phase H: Conflict management and local workspace merging support
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3438083
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
malcomio commentedThis limitation of workspaces isn't obvious from the documentation - I've added some info to https://www.drupal.org/docs/8/core/modules/workspace/using-workspaces
Comment #3
amateescu commentedMarking as postponed on #2867707: WI: Phase H: Conflict management and local workspace merging support.
Comment #4
djdevinIn our case, merging wasn't necessary, all derivatives are based off of the currently published version so it wasn't a big deal.
This functionality is also necessary for a situation like this:
- Live site
- Promo A
- Promo A takedown
- Promo B
Otherwise you have to wait until the Promo A takedown to start working on Promo B.
I removed the constraint and it seems to work fine - order of versioning is kinda wonky since the latest version might not be the content that is going to go out through live publishing. It might be useful to add a column on that page to show that a revision belongs to which workspace.
There are some issues with Layout Builder editing (and maybe others) because it calls EntityRepositoryInterface::getActive() which always returns the latest revision. It needs to somehow provide the latest revision in the current workspace instead. Otherwise if you're in a workspace and you go to edit, it will load the most recent revision even if it's live or in a different workspace.
Comment #5
doxigo commentedI'd say this is rather a blocker for any big organization to ever consider to use Workspace, big organizations constantly update their live instance, so this should be available only as an opt-in option.
Comment #6
djdevinI fixed a few issues from my PoC in #4 and published it here: https://www.drupal.org/project/workspaces_parallel
Caveat, there is no reintegration so any live changes just get overwritten when you publish (only content that was edited within the Workspace).
Comment #7
amateescu commentedComment #8
djdevinAdded an MR which is basically https://www.drupal.org/project/workspaces_parallel
Some fluff in here like adding a configuration, but essentially we have to change the behavior of EntityRepository so that it loads not just the latest version, but only the latest version within the current workspace. This doesn't affect the current behavior of viewing or the node edit form (they seem to load the workspace-aware revision) but seems to affect anything that uses getActiveMultiple() which includes Layout Builder.
If you want to verify this, just make EntityWorkspaceConflictConstraintValidator return true temporarily (without this patch).
1. Enable layout builder on basic page
2. Create a piece of content in Live and create three workspace, One Two Three
2. Make a layout builder change in each workspace
3. Make a layout builder change in Live
4. Switch to the "Two" workspace
5. Edit the layout (discard changes just to make sure)
You'll see the Live changes, because that's the latest revision. But it should be returning the Two workspace changes. getActive() doesn't seem to call hook_entity_preload().
Comments welcome, has been in use for a while on a production site with tiny issues here and there.
Two outstanding issues I have to track down:
1. Sometimes publishing results in two active revisions, I fixed this in the module but looking for a better way in core.
2. Discarding revisions only discard the revisions that are newer than the active revisions in the live workspace. It needs to delete all of them. This is functionality provided by https://www.drupal.org/project/wse, but it uses a method in core. Workaround is to delete the revisions manually from the revisions tab.
This one is a problem because you can re-use a Workspace, so discarding a change in a re-opened workspace would discard all historical changes. I think in order to fix this we need to disassociate the revision with the workspace when a workspace is published. Maybe some logic would work to only delete revisions that have been added to the Workspace since it was reopened but I haven't figured that out yet.
Comment #10
djdevinComment #11
smustgrave commentedSeems to have pipeline errors
Going to post into #workspaces too
Comment #12
djdevinThe discard issue is fixed if you use WSE in combination with this change, because then it gets all the revisions associated with a Workspace and not just the ones since the current version.
#3494770: Simplify getAssociatedRevisions() and getAssociatedInitialRevisions() from core