Problem/Motivation

Both Workspace and Content Moderation make use of pending revisions to handle their draft content. This causes peculiar behavior when both modules are enabled and moderating the same entity types.

Also "workspace" and "workspace association" entity types appear in a Content Moderation workflow settings as entity types which can have a workflow assigned to them.

Specific example:

  1. Enable Workspace and Content Moderation
  2. Enable the Article content type in the Editorial workflow
  3. Switch to the stage workspace
  4. Create an article and publish it
  5. Edit the article and set the moderation state to "draft"
  6. The "draft" revision is loaded by default, there is no latest tab, and navigating to /node/1/latest returns "Access denied"

Proposed resolution

Prevent both modules from being installed together.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

timmillwood created an issue. See original summary.

timmillwood’s picture

One other incompatibility is "workspace" and "workspace association" entity types appear in a Content Moderation workflow settings as entity types which can have a workflow assigned to them.

timmillwood’s picture

Issue summary: View changes

Specific example:

  1. Enable Workspace and Content Moderation
  2. Enable the Article content type in the Editorial workflow
  3. Switch to the stage workspace
  4. Create an article and publish it
  5. Edit the article and set the moderation state to "draft"
  6. The "draft" revision is loaded by default, there is no latest tab, and navigating to /node/1/latest returns "Access denied"
amateescu’s picture

amateescu’s picture

I opened #2971779: Disallow moderation of internal entity types for disallowing moderation on the workspace association entity type, and I think that allowing workspaces themselves to be moderatable is actually a nice feature :)

fabianx’s picture

Different question: Why would you need content moderation features if you have workspaces?

What you want is an per entity workflow state (and one for the whole workspace as well) - yes:

https://www.drupal.org/project/entity_workflow

but you want workspaces to manage the actual revisions for that.

And even for content moderation of just one entity, you want to still have a micro workspace, because you have:

- paragraphs
- (panelizer) layout
- translations of all that

be all in one per-entity-workspace as else that really does not make sense.

e.g. Complex workflows we have work like that:

- When all entities are in state 'review', then allow to transition the workspace to the 'review' state
- Allow translators to import translations, then check that the translation looks good in context of the site and put the state of the translated reviewed entities to ''

etc.

So my proposal to solve that would be:

- Base content_moderation on per-entity micro-workspaces WHILE not being in a workspace itself (but hide all the complexity)
- Have content_moderation only do the workflows in the future

Alternatively:

- Have workspaces conflict with content_moderation and add a new workflows module as replacement for the workflow functionality of content_moderation
- Deprecate content_moderation once workspaces is stable

timmillwood’s picture

Why would you need content moderation features if you have workspaces?

One idea has always been, that content authors can add content to their workspace, then mark the workspace as "Needs review", the reviewer can then mark the workspace as "Approved". This could automatically replicate content upstream, or just inform the content author that they have approval to replicate the content.

Deprecate content_moderation once workspaces is stable

That's an interesting through. However, the only reason the Workflow initiative was tasked with adding Content Moderation in core rather than just starting with Workspace was because Content Moderation was seen as the 80% use case.

amateescu’s picture

Status: Active » Needs review
StatusFileSize
new801 bytes

As discussed in the "roadmap to Workspace beta" call, the initial step here is to disallow the Workspace module from being installed alongside Content Moderation.

Opened a followup to provide a minimal implementation which would allow them to work together: #2982937: Allow workspace integration to be enable per entity type and bundle

amateescu’s picture

sam152’s picture

+++ b/core/modules/workspace/workspace.install
@@ -8,6 +8,21 @@
+function workspace_requirements($phase) {
+  $requirements = [];
+  if ($phase === 'install' && \Drupal::moduleHandler()->moduleExists('content_moderation')) {
+    $requirements['workspace_incompatibility'] = [
+      'severity' => REQUIREMENT_ERROR,
+      'description' => t('Workspace can not be installed when Content Moderation is also installed.'),
+    ];
+  }
+
+  return $requirements;
+}

What happens if you install workspace first? I think these checks are only invoked for the module you are installing and not all the modules already installed.

amateescu’s picture

StatusFileSize
new1.62 KB
new860 bytes

That's hilarious :D And it goes to show that hook_requirements() is not good fit for declaring module incompatibilities. I think we have three options:

1) mirror this hook_requirements() implementation in content_moderation

2) add a way for modules to declare the incompatibility with another module in its info.yml file, something like:

dependencies:
 - !<module_name>

3) introduce a ModuleInstallValidatorInterface, similar to the existing ModuleUninstallValidatorInterface

Let's do 1) for now since it's the simplest option.

amateescu’s picture

StatusFileSize
new1.63 KB
new611 bytes

Oops.

The last submitted patch, 8: 2971699-8.patch, failed testing. View results

The last submitted patch, 11: 2971699-11.patch, failed testing. View results

timmillwood’s picture

Status: Needs review » Needs work

[cross post]

timmillwood’s picture

Status: Needs work » Needs review
timmillwood’s picture

Status: Needs review » Reviewed & tested by the community

Looks good now, thanks!

plach’s picture

Not sure about changing stable code (and introducing new strings) to support experimental code. I can't think of another simple solution right now, but I'd be happier if we could find one.

amateescu’s picture

A simpler solution would be #2982954: Allow modules to declare conflicts with other modules in their info.yml file, but I'm not sure that can be done before 8.6.0-alpha1.

Another solution is to implement the "workspace integration by entity type and bundle" approach, but it would require similar changes to stable code (Content Moderation), because it also has to be workspace-aware and not allow people to enable CM support on an entity type already configured with workspace support.

However, the proper long-term solution (8.7) is to allow all the modules that work with pending revisions to interact seamlessly, through the revision tree proposal/idea.

timmillwood’s picture

I agree with @amateescu that this is currently the best course of action. Maybe it's worth explaining the reasoning within both install files, with a @todo to remove once #2982954: Allow modules to declare conflicts with other modules in their info.yml file is in.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 12: 2971699-12.patch, failed testing. View results

timmillwood’s picture

Status: Needs work » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Needs review

Agreed with @plach that it's better that stable modules don't have references to / code affected by experimental modules. Especially since if Workspaces doesn't make it to beta for 8.6 and ends up getting postponed to 8.7 (which, I hasten to add, we all hope won't happen!!), we'd then be left with dead code in core, which is definitely not ideal.

He and I kicked this around a bit. It seems like we need to account for the following situations:

1. I already have Content Moderation installed, now I want to play around with Workspaces.
2. I already have Workspaces installed, now I want to play around with Content Moderation.
3. I enable both Content Moderation and Workspaces at the same time.

I believe all three cases are solved by the current hook_install() approach, since case 3 will end up changing to case 1, since Content Moderation is alphabetically first and therefore will get enabled first. And agreed that introducing new functionality or dependencies on stale core issues isn't a good idea. There's a hook_modules_installed() but the best this could do is fire a warning that's easily missed/skipped over.

However, while Workspaces integration isn't per-entity type+bundle, I'm curious if we could leverage the fact that Content Moderation's integration is done that way, and have Workspaces hook_form_alter() the config form that allows you to enable Content Moderation on any content/block types, to replace the form there with a message about you not being able to run both modules at once. That seems like it solves case 1 and 3 with not-too-much-code, which could all live in the experimental module where the compatibility problem's being introduced.

What do you think?

timmillwood’s picture

Status: Needs review » Needs work

@webchick - I think that could work and a good alternative to adding workspace related code in Content Moderation.

Just to clarify my understanding:

  • Install Content Moderation then Workspace or install both at the same time (because they install alphabetically) - The error in workspace_requirements() will be thrown.
  • Install Workspace then Content Moderation - On the Workflow edit page the entity types that can be added to workspaces will either not appear on the list or have a strike through, and have a dsm() explaining why.
catch’s picture

workspace integration by entity type and bundle

This doesn't really seem viable to me. The whole model of workspaces is that you can make changes within a workspace and publish the whole thing at once. If entity types/bundles become admin configurable, then unless we prevent editing the non-workspace-enabled entities within workspaces, the behaviour will be very confusing. We already have the issue of path aliases and etc. which can't be workspace enabled.

I kind of feel like hook_requirements() (including in content_moderation) is the cleanest option here. We're not adding a feature or dependency, just avoiding an incompatibility, and it could have a @todo pointing to #2982954: Allow modules to declare conflicts with other modules in their info.yml file.

timmillwood’s picture

Status: Needs work » Needs review
StatusFileSize
new2.96 KB
new2.83 KB
new83.44 KB

Implemented as a form_alter, removing all code from content_moderation, here's how it looks:

amateescu’s picture

Status: Needs review » Needs work

The approach suggested by @webchick in #24 and implemented in #27 seemed "viable" to do, but I have to agree with @catch that we are breaking the whole premise of workspaces if we disallow entity types from being a part of a workspace when they could have been.

amateescu’s picture

Btw, #2982954: Allow modules to declare conflicts with other modules in their info.yml file is not really stale, it was just opened yesterday with an initial patch :) Someone with actual knowledge of the module (installer) system could easily make it work, IMO

webchick’s picture

Oh, I'm sorry, I'm confusing that with some much older issue.

I'm also fine with @catch's proposal, btw. :) I think @plach was just looking for a second opinion. That said, #27 looks good to me from a screenshot POV!

timmillwood’s picture

Status: Needs work » Needs review

"workspace integration by entity type and bundle" is not implemented in the patch from #27, this is still set for the follow up #2982937: Allow workspace integration to be enable per entity type and bundle, but I agree with #26 and #28 that it would be the wrong direction.

The patch in #27 supports the two different outcomes described in #25.

I believe #27 is the best way forward. It throws the hook_requirements install error if Content Moderation is installed first and Workspace is tried to be installed afterwards. If Workspace is installed first, and Content Moderation after, the warning on the workflow entity form shown in the screenshot of #27 will be displayed.

plach’s picture

@catch:

I'm +1 on #27: it allows to handle all the three use cases we identified without forcing us to touch stable code to support Workspace. The fact that Content Moderation can be enabled per bundle provides us a UI to alter, so that we can state that Workspace is incompatible with it, but this does not imply that we must do #2982937: Allow workspace integration to be enable per entity type and bundle: I also believe that Workspace should act on every aspect of the site, if we are ever able to support that.

Since basically this change makes CM unusable when WS is enabled, we could also choose to grey out the UI entirely or perform something more radical, but I wouldn't spend too much time on this. Hopefully enabling WS and then CM is not the 80% use case.

Of course we need a green patch :)

catch’s picture

I'd prefer to go with #12 with the hook_requirements() compared to #27 - it's closer to the behaviour once .info.yml files support incompatibility, and it's already green. I think we can just exclude hook_requirements() from the 'no code about experimental modules' rule since it's not even runtime.

catch’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.63 KB

Re-uploading an RTBC-ing. If someone has strong objections please say so but for me it's clean and it works.

timmillwood’s picture

@catch - personally I'm fine with that. I do think #27 is a nice solution to the problem, but is also gives an inconsistent result depending on the order modules are installed. The test fixes look pretty simple though if we do want to go on that route.

In the unfortunate circumstance that Workspace doesn't make it to Beta, then we'll just need to remember to revert this commit, or remove the code from content_moderation.install.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Ok, sounds like we have an agreed-upon path forward! :)

Committed and pushed to 8.6.x. Thanks!

  • webchick committed 5409fff on 8.6.x
    Issue #2971699 by amateescu, timmillwood, catch, plach, Sam152: Content...
chris matthews’s picture

Extremely minor nitpick, but I thought it was at least worth mentioning.

Content Moderation can not be installed when Workspace is also installed.

Should can not be changed to cannot? http://grammarist.com/usage/cannot-or-can-not

plach’s picture

You're welcome to open a (novice?) follow-up ticket to discuss/implement your suggestion :)

If you do please post the link here.

jibran’s picture

DER and Workspace both override EFQ. Right now DER v2 EFQ integration will break if the workspace module will be enabled. Related DER issue is #2835542-11: Utilize service decorator instead of taking over entire EFQ service.

amateescu’s picture

Component: workspace.module » workspaces.module

Fix component following module rename.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mpp’s picture

I'm puzzled. Drupal 8.6 released with Workspace as an experimental module but it's not compatible with Content Moderation which is now stable in core, how can this be?

timmillwood’s picture

@mpp The two modules are simply incompatible with each other. As Drupal core adds features and modules it was bound to happen that two things are incompatible with each other.

The incompatibility comes down to the fact that they both allow pending revisions to be created and track them in different ways. Allowing both to create pending revisions at the the same time leads to internal confusion. Ideally down the road we need to find a generic way to track the revisions and allow modules to live in harmony, but I believe we have bigger things to work on than allowing these modules to live side by side.

webdrips’s picture

@timmillwood I hope you see this since the issue is closed, but I for one would love to see both modules be allowed to work together.

amateescu’s picture

@webdrips, there's a very good chance for them to work together in 8.7. Follow #3023194: [PP-2] Add parallel revisioning support and #2725523: Add a revision_parent field to revisionable entities for that effort.

webdrips’s picture

@amateescu thank you!