Problem/Motivation
Workspaces is built for staging and publishing changes to multiple entities at once. This concept of editing multiple entities is somewhat baked into the workspaces UI - e.g. each set of changes is a 'workspace' which can contain one or more entities.
Content moderation only tracks one entity at a time.
Actual Drupal entities are often composites of multiple different entities. For example an article has a path alias, which is an entity. Creating an article may involve adding a path alias on the entity form, which creates another entity. Editing the node and updating the path alias, updates the path alias. Content moderation doesn't know anything about the non-node entities so your path alias is changed on the live site, even if the node edit itself is in moderation.
What we ought to have, is the multi-entity tracking of workspaces, but without the overhead of having a separate 'workspaces' concept when you are mostly dealing with 'one' entity at a time rather than sets of changes.
Steps to reproduce
Proposed resolution
Done: 1. Create a 'workspaces_ui' module which holds the UI bits of workspaces. workspaces will need an update path to install the new module. #2972622: Split the workspaces UI into a separate module
2. Add a 'workflow' field to workflows module, this exists in contrib in the entity_workflows module but should really live in core for re-use #2835545: Provide a Workflow FieldType that references a workflow entity and tracks the current state of an entity
3. Add a 'managed' boolean and 'provider' string to the workspaces entity as base fields, existing issue #3095414: Add the concept of workspace providers. This lets us identify workspaces that are not created manually via the workspaces UI and list/treat them differently.
All of the above steps are fairly well defined and prerequisites to everything else. The next bit is a bit more TBD but is where we got to after discussions with @amateescu this week and @fabianx a few weeks ago.
4. Create a new contrib module, to eventually replace content_moderation. When enabled and an entity bundle is moderated, creating or editing an entity via the entity form will implicitly create a workspace and save any changes to implicitly edited entities (path aliases, created media entities etc.) within that workspace. When the content workflow goes to published, it will then be published alongside all the other entities that are tracked with it.
5. We will need some kind of way to make this interoperable with advanced workspaces workflow, e.g. on the 'moderated content' page, add a bulk operation to move items to a 'real'/non-managed workspace. This can be a later step.
When we have a stable contrib module, it will be possible to mark content_moderation as deprecated in core and move it to contrib. The most basic migration path would be 'resolve the moderation state of entities in your site, uninstall content_moderation, install the new module'.
Discussed refactoring content_moderation with @amateescu but we think that there will be a fair bit of custom code that relies on content_moderation implementation details out there, so instead of trying to create a seamless upgrade path for all of those sites in a single minor release and potentially failing, better to let them migrate (or not) on their own schedule. But by having the new module in Drupal CMS we should stop adding to content_moderation usage as quickly as is currently happening which will start new sites off on a good footing.
If we come up with a way to do an in-place refactoring after all, then all of steps 1-3 are exactly the same anyway.
Comments
Comment #2
catch.
Comment #5
catchComment #6
amateescu commentedComment #7
aaronmchaleThis is a really clever idea, and could really solve some interesting problems! I could see this being used to allow, for example, paragraphs on a node to all move with the node through the workflow.
One thing we need to be mindful of is the large number of sites using content moderation with existing complex workflows. So we need to be clear that not all workflows are simply draft/review/publish. For instance, I'm on a project right now where we have content moderation workflows with many stages and transitions, and some branching logic. For instance, we essentially have different "tracks" within a workflow that content can be on depending on other factors. The fact that it's easy to set the moderation state of a node in-code, just by calling
->set('moderation_state', '...')really helps enable these more complex workflows.If we can continue to maintain the power and flexibility of content moderation, this could be very powerful stuff!
Comment #8
catchHopefully this will stay exactly the same.
The current idea is that there is a primary entity for a content moderation workspace, e.g. when you edit or create a node, we create a workspace for that entity and then edits to other entities within that workspace are included, but the workflow status is still tracked on the node itself.
If you edit a different node that has workflow enabled, then that node gets its own workspace too.
When the workflow state moves to published, this publishes the workspace and the other downstream changes (media, path aliases, menu links, paragraphs etc.) are published alongside it. This way the current UX and data model would be preserved as closely as possible, e.g. we'd be adding extra data but not necessarily moving or removing what content_moderation already stores.
If you read the above and think 'what if I want different workflow states for different entities though'? Then that wouldn't be possible with either the old or new content_moderation but it's already possible with workspaces + https://www.drupal.org/project/entity_workflow today - so the answer would be to enable workspaces_ui module and set things up how you want in that case.
Comment #9
aaronmchaleThanks for explaining that @catch, that does sound like a very cool idea then! I can definitely see the potential in this!
Comment #10
catchComment #11
catchComment #12
catchComment #13
larowlanComment #14
geek-merlinComment #15
catchWhat's the next issue here?
Comment #16
amateescu commentedHere it is :) #3557205: Implement dependency tracking for moderated content using workspaces
Comment #18
rakhimandhania commentedComment #19
rakhimandhania commentedComment #20
rakhimandhania commented