Problem/Motivation
The change in #3266436: Convert EventSeries event_instances field to be a computed field introduced a bug where saving an event throws an exception if the Content Moderation module is also installed.
Steps to reproduce
- Enable the Content Moderation module and the current 2.0.x-dev version of Recurring Events.
- Go to /events/add/default, create a daily recurring event, and save.
- Edit the event and save again.
Expected result: The event saves.
Actual result: An exception is thrown as shown below.
The website encountered an unexpected error. Please try again later.
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 143 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).
content_moderation_entity_field_access('edit', Object, Object, Object)
call_user_func_array('content_moderation_entity_field_access', Array) (Line: 392)
Drupal\Core\Extension\ModuleHandler->invoke('content_moderation', 'entity_field_access', Array) (Line: 347)
Drupal\Core\Entity\EntityAccessControlHandler->fieldAccess('edit', Object, Object, Object, ) (Line: 154)
Drupal\Core\Field\FieldItemList->access('edit', Object) (Line: 166)
Drupal\Core\Entity\EntityConstraintViolationList->filterByFieldAccess(Object) (Line: 191)
Drupal\Core\Entity\ContentEntityForm->validateForm(Array, Object) (Line: 334)
Drupal\recurring_events\Form\EventSeriesForm->validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'eventseries_default_edit_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('eventseries_default_edit_form', Array, Object) (Line: 588)
Drupal\Core\Form\FormBuilder->processForm('eventseries_default_edit_form', Array, Object) (Line: 320)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Proposed resolution
The cause seems to be that recurring_events_entity_base_field_info_alter() does not include the entity_type in the field definition for the event_instances computed field, resulting in a NULL $entity_type_id parameter being passed to EntityTypeManager::getDefinition() when Content Moderation checks field access. Setting ->setTargetEntityTypeId('eventseries') in the field definition resolves the issue.
Issue fork recurring_events-3272361
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
muriqui commentedhttps://git.drupalcode.org/issue/recurring_events-3272361/-/commit/a83c7...
Comment #7
owenbush commentedThank you for this patch. Given this is quite critical I have gone ahead and merged it straight away into the dev branches for 8.x-1.x and 2.0.x