Remove old RequestStack shim

Created on 20 March 2023, almost 2 years ago
Updated 20 April 2023, almost 2 years ago

Problem/Motivation

I am encountering errors when trying to add DAM Assets in Drupal 10 with Symfony 6. Specifically, I am receiving the following error messages when clicking on Insert Media icon from CKEditor:

TypeError: Drupal\acquia_dam\Form\EmbedSelectForm::__construct(): Argument #1 ($requestStack) must be of type Drupal\Core\Http\RequestStack, Symfony\Component\HttpFoundation\RequestStack given, called in /var/www/docroot/modules/contrib/acquia_dam/src/Form/EmbedSelectForm.php on line 62 in Drupal\acquia_dam\Form\EmbedSelectForm->__construct() (line 49 of /var/www/docroot/modules/contrib/acquia_dam/src/Form/EmbedSelectForm.php)
#0 /var/www/docroot/modules/contrib/acquia_dam/src/Form/EmbedSelectForm.php(62): Drupal\acquia_dam\Form\EmbedSelectForm->__construct(Object(Symfony\Component\HttpFoundation\RequestStack), Object(Drupal\acquia_dam\ImageStyleHelper), Object(Drupal\Core\Entity\EntityTypeManager))
#1 /var/www/docroot/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php(28): Drupal\acquia_dam\Form\EmbedSelectForm::create(Object(Drupal\Core\DependencyInjection\Container))
#2 /var/www/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(193): Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition('Drupal\\acquia_d...')
#3 /var/www/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(230): Drupal\Core\Form\FormBuilder->getFormId('Drupal\\acquia_d...', Object(Drupal\Core\Form\FormState))
#4 /var/www/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(222): Drupal\Core\Form\FormBuilder->buildForm('Drupal\\acquia_d...', Object(Drupal\Core\Form\FormState))
#5 /var/www/docroot/modules/contrib/acquia_dam/src/Plugin/views/field/MediaLibrarySelectForm.php(210): Drupal\Core\Form\FormBuilder->getForm('Drupal\\acquia_d...', 'acquia_dam_imag...', '461')
#6 /var/www/docroot/modules/contrib/acquia_dam/src/Plugin/views/field/MediaLibrarySelectForm.php(192): Drupal\acquia_dam\Plugin\views\field\MediaLibrarySelectForm::buildEmbedForm(Object(Drupal\Core\Form\FormState), Object(Symfony\Component\HttpFoundation\Request), Array)
#7 [internal function]: Drupal\acquia_dam\Plugin\views\field\MediaLibrarySelectForm::updateWidgetToNext(Array, Object(Drupal\Core\Form\FormState), Object(Symfony\Component\HttpFoundation\Request))
#8 /var/www/docroot/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php(69): call_user_func_array(Array, Array)
#9 /var/www/docroot/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php(109): Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse(Object(Symfony\Component\HttpFoundation\Request), Array, Object(Drupal\Core\Form\FormState), Array)
#10 [internal function]: Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber->onException(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#11 /var/www/docroot/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#12 /var/www/vendor/symfony/http-kernel/HttpKernel.php(221): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...')
#13 /var/www/vendor/symfony/http-kernel/HttpKernel.php(89): Symfony\Component\HttpKernel\HttpKernel->handleThrowable(Object(Drupal\Core\Form\FormAjaxException), Object(Symfony\Component\HttpFoundation\Request), 1)
#14 /var/www/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /var/www/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /var/www/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /var/www/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /var/www/docroot/modules/contrib/shield/src/ShieldMiddleware.php(270): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /var/www/docroot/modules/contrib/shield/src/ShieldMiddleware.php(137): Drupal\shield\ShieldMiddleware->bypass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /var/www/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\shield\ShieldMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /var/www/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /var/www/docroot/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /var/www/docroot/core/lib/Drupal/Core/DrupalKernel.php(686): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /var/www/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#25 {main}

Steps to reproduce

Make sure you have Drupal 10 and Synfony 6,
Also the Insert Media icon should be added in CKEditor 5
Lets say body field has CKEditor 5 with Insert Media icon.
Click in Insert Media icon
Select any DAM Image
Click on Next: Select Format button
Check Recent Log Messages to see the error.

Proposed resolution

To use Symfony\Component\HttpFoundation\RequestStack instead of Drupal\Core\Http\RequestStack
https://www.drupal.org/node/3265357

Remaining tasks

To test careful

User interface changes

No

API changes

No

Data model changes

No

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇲🇩Moldova sandzel Chisinau

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024