Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Workbench Moderation assumes that all revisionable content entities have bundles.
If there is a contrib module that defines a revisionable content entity without bundles the following error is thrown:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 130 of /home/timmillwood/Code/drupal1/core/lib/Drupal/Core/Entity/EntityTypeManager.php).
An example of this is the Multiversion module which introduces Workspaces, Workspaces are revisionable but don't have bundles. I was going to add a single default bundle to the Workspace entity until I discovered that because Multiversion module makes the User entity also revisionable, it causes the same issue there.
Comment | File | Size | Author |
---|---|---|---|
#19 | interdiff-2656742.txt | 722 bytes | Crell |
#19 | 2656742-bundles.patch | 7.71 KB | Crell |
Comments
Comment #2
timmillwoodAfter speaking with @Crell it looks like the fix here is to make WBM only work on bundleable entities.
Comment #4
Crell CreditAttribution: Crell as a volunteer commentedI'm actually a bit unclear why this is breaking at all. The code that determines what entities to even try to moderate is:
That is, it's selecting only those config entities that are the bundle definition of something, and that something is revisionable. So if Users are not bundleable, then there wouldn't even be such an object, so why is it passing at all? It should get filtered already. It should just be ignoring it.
Tim, can you post a backtrace?
Comment #5
timmillwoodI looks as though the issue is coming from
\Drupal\workbench_moderation\Plugin\Field\FieldWidget\ModerationStateWidget::formElement
, this is added in\Drupal\workbench_moderation\BaseFieldInfo::entityBaseFieldInfo
. The attached patch should fix the issue.Comment #6
timmillwoodI am now getting the following uncaught exception when I visit "/admin/structure/types".
Comment #7
timmillwoodIt looks as though commit 4179e67ef780f24c2b46bb4dd38d23cf85220662 in branch 2656742-bundles is causing the issue in #6.
So with the 8.x-1.x branch, and the patch from #5, multiversion works, until I try to save a node, then I get the error:
Comment #8
timmillwoodIt looks as though the issue in #7 is a definitely a conflict between WBM and Multiversion.
Comment #10
Crell CreditAttribution: Crell at Palantir.net for Acquia commentedTim, please try the attached patch. It folds BaseFieldInfo into EntityTypeInfo, and alters the filter logic in it to only check for entities we've already marked as being moderatable. (That process already should filter for bundleable entities, as above.)
It passes PHPUnit tests for me, but I've not asked Simpletest for its opinion yet.
Comment #11
timmillwood@Crell - This looks good, it produces the same results as my patch in #5, which is good.
I have two issues now with the WBM / Multiversion compatibility, which I still need to work out if they are WBM issues or Multiversion issues.
When saving a node (with moderation):
When using the bundles branch of Multiversion, saving a workspace as draft etc works, but editing a workspace:
Comment #12
timmillwood@Crell - I am also getting the following error when editing a user with WBM and Multiversion installed:
I assume we need a check somewhere else. Is it trying to add the "Latest version" tab on the user edit page?
Comment #13
timmillwoodI have fixed the issue:
It was because we have not defined the
links
section of the Workspace entity annotation.So just the two route issues remain.
Comment #14
timmillwoodHow about a patch such as this to prevent against issues like the one in #13.
Comment #16
timmillwoodComment #17
timmillwoodTo overcome the first issue stated in #11 I added the following to workbench_moderation.routing.yml:
However I now get the following issue when viewing the newly created node:
Comment #18
josephdpurcell CreditAttribution: josephdpurcell at Palantir.net for Acquia commentedI've reviewed @Crell's patch 2656742-bundles.patch, and it looks good. I really like the refactoring to use a service instead instantiating a class in
workbench_moderation_entity_base_field_info
.I do have two questions:
1. I see there are @todo's for testing. While this is out of scope for this issue, the process of writing the tests may uncover bugs and further refactoring. Is there a plan for those tests to be written at some point>
2. Why not use {@inheritdoc}?
Comment #19
Crell CreditAttribution: Crell at Palantir.net for Acquia commented1) We should at some point. Most of those are left over from larowlan's original work. I didn't bother removing them as I went.
2) Because I originally wrote the method in the class then moved it to the interface, but forgot to fix the docblock afterward. :-) Fixed here.
Comment #22
josephdpurcell CreditAttribution: josephdpurcell at Palantir.net for Acquia commentedThis has been committed to 8.x-1.x. Nice work!
Comment #24
MrSchoolcraft CreditAttribution: MrSchoolcraft as a volunteer commented@crell I am using ECK in 8 for the UI to create my types and bundles. However, once diving in to edit and set up fields on my bundle, I was expecting to see the 'manage moderation' tab there buy do not see it.
Is there something I'm missing on being able to make ECK created entities/bundles moderated?