Problem/Motivation

A critical error (white-screen-of-death) occurs when trying to add or edit a cookie category. The error thrown is

TypeError: Argument 3 passed to Drupal\eu_cookie_compliance\Plugin\EuCcClearCache::__construct() must be an instance of Drupal\Core\Entity\EntityTypeManager, instance of Drupal\webprofiler\Entity\EntityManagerWrapper given, called in /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262 in Drupal\eu_cookie_compliance\Plugin\EuCcClearCache->__construct() (line 70 of /var/www/html/web/modules/contrib/eu_cookie_compliance/src/Plugin/EuCcClearCache.php)

#0 /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(262): Drupal\eu_cookie_compliance\Plugin\EuCcClearCache->__construct()
#1 /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService()
#2 /var/www/html/web/modules/contrib/eu_cookie_compliance/src/Form/CookieCategoryForm.php(54): Drupal\Component\DependencyInjection\Container->get()
#3 /var/www/html/web/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php(28): Drupal\eu_cookie_compliance\Form\CookieCategoryForm::create()
#4 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php(214): Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition()
#5 /var/www/html/web/modules/contrib/devel/webprofiler/src/Entity/EntityManagerWrapper.php(177): Drupal\Core\Entity\EntityTypeManager->getFormObject()
#6 /var/www/html/web/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php(69): Drupal\webprofiler\Entity\EntityManagerWrapper->getFormObject()
#7 /var/www/html/web/core/lib/Drupal/Core/Controller/FormController.php(58): Drupal\Core\Entity\HtmlEntityFormController->getFormObject()
#8 /var/www/html/web/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult()
#9 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
#10 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#11 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(578): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#13 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#14 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#16 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle()
#17 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle()
#18 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#19 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#20 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle()
#21 /var/www/html/web/modules/contrib/devel/webprofiler/src/StackMiddleware/WebprofilerMiddleware.php(38): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#22 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle()
#23 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#24 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(717): Stack\StackedHttpKernel->handle()
#25 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#26 {main}

In this case I've the webprofiler module installed wich decorates the entity-type.manager service using it's own implementation. As the EuCcClearCache cache plugin injects the EntityTypeManager implementation instead of its interface the site crashes. This will affect any site using a decorate version of the entity-type.manager service.

Steps to reproduce

  1. Install and enable eu_cookie_compliance module with latest version (currently 1.16)
  2. Install devel module and enable webprofiler module
  3. Visit /admin/config/system/eu-cookie-compliance/categories and click Add cookie category
  4. WSoD occurs, check the logs for backtrace

Proposed resolution

Refactor EuCcClearCache::__construct() signature to accept EntityTypeManagerInterface instead of EntityTypeManager

Remaining tasks

  • Provide a patch
  • Write some tests perhaps

User interface changes

NA

API changes

NA

Data model changes

NA

Command icon 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

d70rr3s created an issue. See original summary.

d70rr3s’s picture

d70rr3s’s picture

Assigned: d70rr3s » Unassigned
Status: Active » Needs review

MR set, call for NR

svenryen’s picture

Status: Needs review » Fixed

I reviewed it on tugboat. When I click Add category or Edit a category I see no wsod. Thanks for the MR on Gitlab!

neslee canil pinto’s picture

Version: 8.x-1.16 » 8.x-1.x-dev

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.