- Issue created by @Rob230
- Merge request !3Issue #3528221 by rob230: This module breaks Drupal core workflow add form → (Merged) created by Rob230
- Status changed to Fixed
11 days ago 5:45pm 3 October 2025
If this module is installed then it's impossible to add a content moderation workflow.
The website encountered an unexpected error. Try again later.
Error: Call to a member function get() on null in Drupal\workflows\Entity\Workflow->getTypePlugin() (line 121 of core/modules/workflows/src/Entity/Workflow.php).
content_moderation_entity_access()
call_user_func_array() (Line: 416)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}() (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 415)
Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 100)
Drupal\Core\Entity\EntityAccessControlHandler->access() (Line: 329)
Drupal\Core\Entity\EntityBase->access() (Line: 33)
commerce_license_entity_field_form_alter() (Line: 552)
The issue is here in core content_moderation_entity_access()
:
if ($entity instanceof WorkflowInterface) {
$configuration = $entity->getTypePlugin()->getConfiguration();
// ... [snip]
}
In this case $entity
is a blank Workflow entity and getTypePlugin()
looks like this:
public function getTypePlugin() {
return $this->getPluginCollection()->get($this->type);
}
Therefore getPluginCollection()
returns null because there is no plugin - there is no workflow yet. So it calls get()
on null.
The issue arises because commerce_license_entity_field_form_alter()
triggers an access check on the $entity
:
$entity = $form_object->getEntity();
// ... [snip]
// Don't bother doing anything if the user can't delete the entity anyway.
if (!$entity->access('delete')) {
return;
}
The function can exit early if the entity doesn't exist:
if (!$entity->id()) {
return;
}
This resolves the problem. Since this function only cares about the delete action, it doesn't ever need to care about a non-existent entity.
Active
2.0
Code