- Issue created by @welly
I have encountered the same issue, the attached patch fixes it for me. Although the patch is logically correct as it prevents `hook_entity_view()` from running on non content entities (like form modes), I think the actual root cause for the circular reference should also be resolved.
Steps to reproduce:
- Clear the plugin cache
drush cc plugin
. - Visit any page.
hook_entity_type_alter()
will get invoked and will reach to a point wherehook_entity_view()
is invoked as well, resulting in the mentioned error.
Full stack trace:
The website encountered an unexpected error. Please try again later. Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "business_rules.processor", path: "business_rules.event_listener -> business_rules.processor -> business_rules.util -> eca.service.token -> eca.token_data.current_user". in Drupal\Component\DependencyInjection\Container->get() (line 146 of core/lib/Drupal/Component/DependencyInjection/Container.php). Drupal::service('business_rules.processor') (Line: 347) business_rules_entity_load(Array, 'entity_form_mode') (Line: 431) Drupal\Core\Entity\EntityStorageBase->Drupal\Core\Entity\{closure}(Object, 'business_rules') (Line: 405) Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_load', Object) (Line: 432) Drupal\Core\Entity\EntityStorageBase->postLoad(Array) (Line: 353) Drupal\Core\Entity\EntityStorageBase->loadMultiple() (Line: 114) Drupal\Core\Entity\EntityDisplayRepository->getAllDisplayModesByEntityType('form_mode') (Line: 85) Drupal\Core\Entity\EntityDisplayRepository->getAllFormModes() (Line: 516) business_rules_entity_type_alter(Array, NULL, NULL) (Line: 562) Drupal\Core\Extension\ModuleHandler->alter('entity_type', Array) (Line: 334) Drupal\Core\Plugin\DefaultPluginManager->alterDefinitions(Array) (Line: 123) Drupal\Core\Entity\EntityTypeManager->findDefinitions() (Line: 175) Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22) Drupal\Core\Plugin\DefaultPluginManager->getDefinition('user', ) (Line: 132) Drupal\Core\Entity\EntityTypeManager->getDefinition('user') (Line: 253) Drupal\Core\Entity\EntityTypeManager->getHandler('user', 'storage') (Line: 192) Drupal\Core\Entity\EntityTypeManager->getStorage('user') (Line: 41) Drupal\eca\Token\CurrentUserDataProvider->__construct(Object, Object) (Line: 262) Drupal\Component\DependencyInjection\Container->createService(Array, 'eca.token_data.current_user') (Line: 176) Drupal\Component\DependencyInjection\Container->get('eca.token_data.current_user', 1) (Line: 437) Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 276) Drupal\Component\DependencyInjection\Container->createService(Array, 'eca.service.token') (Line: 176) Drupal\Component\DependencyInjection\Container->get('eca.service.token') (Line: 176) Drupal\business_rules\Util\BusinessRulesUtil->__construct(Object) (Line: 262) Drupal\Component\DependencyInjection\Container->createService(Array, 'business_rules.util') (Line: 176) Drupal\Component\DependencyInjection\Container->get('business_rules.util') (Line: 159) Drupal\business_rules\Util\BusinessRulesProcessor->__construct(Object) (Line: 262) Drupal\Component\DependencyInjection\Container->createService(Array, 'business_rules.processor') (Line: 176) Drupal\Component\DependencyInjection\Container->get('business_rules.processor', 1) (Line: 437) Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 240) Drupal\Component\DependencyInjection\Container->createService(Array, 'business_rules.event_listener') (Line: 176) Drupal\Component\DependencyInjection\Container->get('business_rules.event_listener') (Line: 136) Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, Object) (Line: 52) Drupal\business_rules\EventSubscriber\KernelRequestListener->onKernelRequest(Object, 'kernel.request', Object) call_user_func(Array, Object, 'kernel.request', Object) (Line: 142) Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.request') (Line: 135) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81) 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: 709) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
- Clear the plugin cache