The introduction of content_moderation_workspace_access() breaks Workspace in Drupal 8.8.

When upgrading to Drupal 8.8, the site gives the following error:

The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to content_moderation_workspace_access() must be an instance of Drupal\workspaces\WorkspaceInterface, instance of Drupal\multiversion\Entity\Workspace given in content_moderation_workspace_access() (line 284 of core/modules/content_moderation/content_moderation.module).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ju.vanderw created an issue. See original summary.

edward.radau’s picture

I'm running into this as well. Do you use the multiversion module? I believe this is a bug with that module, not Workspace. multiversion module also implements a Workspace Entity which extends an WorkspaceInterface also provided by the multiversion module and there appears to be a conflict with the namespaces as far as I can tell.

agentrickard’s picture

Yes, it would be perfectly fine to move this issue to that module's queue.

agentrickard’s picture

Project: Workspace » Multiversion
Version: 8.x-1.0-beta21 » 8.x-1.x-dev

Moving to the proper queue.

agentrickard’s picture

Here is a _very naive_ and untested patch that merely tries to replace the existing class definition of the Workspace entity with that from core.

I am pretty convinces that if this type of approach fails, the only answer will be an upgrade / migration path.

agentrickard’s picture

Priority: Normal » Critical
Status: Active » Needs review
mattlt’s picture

Status: Needs review » Needs work

Hello,

Patch isn't working for me. It's throwing a different error now…

The website encountered an unexpected error. Please try again later.
Error: Class 'Drupal\workspaces\Entity\Workspace' not found in include() (line 49 of modules/contrib/multiversion/src/Entity/Workspace.php).

Thanks,

•• matt

agentrickard’s picture

Right. It's simply not going to work. The two classes are far too different.

Matroskeen’s picture

I have some general questions to project maintainers:

  1. Do you remember what were the original reasons to use custom Workspace entity instead of Workspace entity provided by core Workspaces module?
  2. How do you think, is it possible to switch to Workspace entity provided by core? And how long it'll take?
Matroskeen’s picture

@jegg responded in Slack:

1. Multiversion was born long before Workspaces went into core. Workspaces from core is based on ideas from Multiversion and Workspace contrib modules. See Workflow Initiative phases for details.

2. When you switch to Workspaces from core, you uninstall Multiversion. If you’ll still need any functionality from Multiversion after that, then that should be part of Multiversion 2.x (which is not implemented).

Thanks!

Matroskeen’s picture

Hi again,

My notes after some investigation:

  1. We can't use Drupal\workspaces\WorkspaceInterface required by content_moderation_workspace_access() because this interface is provided by core Workspaces module (it'll require us to install Workspaces module);
  2. We can't enable Workspaces and Multiversion module at the same time; They both have Workspace entity implementations and they are way too different;
  3. Replacing custom Workspace entity (provided by Multiversion) with core Workspace entity (provided by Workspaces) isn't enough. They are using a different mechanism to store associations between entities and their workspaces;
  4. content_moderation_workspace_access() provides access checking when we publish the whole workspace and especially looking at "publish" action. We don't have this operation in Multiversion/Deploy implementation, so I think we can just apply a workaround and do not call this implementation;
agentrickard’s picture

This seems like it would work.

I was going to propose a core patch that removes the type hint on content_moderation_workspace_access() as a temporary measure until we fix the upgrade path, but I think this is faster.

I can test this today.

agentrickard’s picture

This patch appears to be working in a test of default core (not on a real site).

Not sure what the test fails are about.

Matroskeen’s picture

agentrickard’s picture

Ah, so that patch has to go in first.

mohangathala’s picture

solution provided here : https://www.drupal.org/project/drupal/issues/3145352 and it works for me.