Problem/Motivation
After upgrading to Drupal 10, I get this error on every page:
TypeError: Drupal\notification_message\Cache\Context\RouteEntityUuidCacheContext::__construct(): Argument #1 ($request_stack) must be of type Drupal\Core\Http\RequestStack, Symfony\Component\HttpFoundation\RequestStack given, called in /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 in Drupal\notification_message\Cache\Context\RouteEntityUuidCacheContext->__construct() (line 39 of modules/contrib/notification_message/src/Cache/Context/RouteEntityUuidCacheContext.php).
Drupal\Component\DependencyInjection\Container->createService(Array, 'cache_context.route.entity_uuid') (Line: 177)
Drupal\Component\DependencyInjection\Container->get('cache_context.route.entity_uuid') (Line: 222)
Drupal\Core\Cache\Context\CacheContextsManager->getService('route.entity_uuid') (Line: 184)
Drupal\Core\Cache\Context\CacheContextsManager->optimizeTokens(Array) (Line: 110)
Drupal\Core\Cache\Context\CacheContextsManager->convertTokensToKeys(Array) (Line: 317)
Drupal\Core\Render\RenderCache->createCacheID(Array) (Line: 66)
Drupal\Core\Render\RenderCache->get(Array) (Line: 109)
Drupal\Core\Render\PlaceholderingRenderCache->get(Array) (Line: 282)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 458)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 474)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 51)
__TwigTemplate_988b456cb50530f228651f8732418cfb->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array, Array) (Line: 40)
Twig\TemplateWrapper->render(Array) (Line: 53)
Steps to reproduce
Upgrade a site to Drupal 10.1 and navigate to any page. You get a WSOD (white screen of death) fatal PHP error.
Looking at Drupal\Core\Http\RequestStack, it has this:
@trigger_error('The ' . __NAMESPACE__ . '\RequestStack is deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3265357', E_USER_DEPRECATED);
Proposed resolution
From the change record linked in the deprecation notice:
The Symfony 4 RequestStack BC shim
Drupal\Core\Http\RequestStackis deprecated.It was added to support
RequestStackto have eithergetMainRequest()orgetMasterRequest()methods.Now Drupal 10 has moved to Symfony 6, this shim is no longer needed there and is deprecated for removal in Drupal 11.
There is no replacement, you can use the Symfony classSymfony\Component\HttpFoundation\RequestStackdirectly.
Comments
Comment #2
solideogloria commentedBumping to Critical, since this bug prevent any Drupal site from working at all.
Comment #3
solideogloria commentedComment #4
solideogloria commentedComment #5
solideogloria commentedIt appears that it's fixed in dev. Could we have a new release please?
Comment #6
droath commentedI've created and deployed another tagged release.
Comment #7
solideogloria commentedThank you!