Problem/Motivation
When installing the CAS module, this WSOD error appears:
TypeError: Drupal\cas\DependencyInjection\DeprecatedEventConstants::Drupal\cas\DependencyInjection\{closure}(): Return value must be of type string, Symfony\Component\DependencyInjection\Reference returned in Drupal\cas\DependencyInjection\DeprecatedEventConstants->Drupal\cas\DependencyInjection\{closure}() (line 58 of modules/contrib/cas/src/DependencyInjection/DeprecatedEventConstants.php).
The error pops-up everytime we try to clear cache: drush cr
The only way to get cache rebuild again is to uninstall the module CAS.
PHP: 8.2.24
Drupal: 10.4.4
30 step stack:
array_map() (Line: 58)
Drupal\cas\DependencyInjection\DeprecatedEventConstants->Drupal\cas\DependencyInjection\{closure}() (Line: 40)
Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall() (Line: 55)
Drupal\cas\DependencyInjection\DeprecatedEventConstants->process() (Line: 80)
Symfony\Component\DependencyInjection\Compiler\Compiler->compile() (Line: 767)
Symfony\Component\DependencyInjection\ContainerBuilder->compile() (Line: 1449)
Drupal\Core\DrupalKernel->compileContainer() (Line: 972)
Drupal\Core\DrupalKernel->initializeContainer() (Line: 854)
Drupal\Core\DrupalKernel->updateModules() (Line: 627)
Drupal\Core\Extension\ModuleInstaller->updateKernel() (Line: 248)
Drupal\Core\Extension\ModuleInstaller->install() (Line: 83)
Drupal\Core\ProxyClass\Extension\ModuleInstaller->install() (Line: 504)
Drupal\system\Form\ModulesListForm->submitForm()
call_user_func_array() (Line: 129)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 67)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 597)
Drupal\Core\Form\FormBuilder->processForm() (Line: 326)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 49)
Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)The module
Issue fork cas-3513857
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
bkosborneI wonder if you have an invalid service definition in your site somewhere. I can't reproduce this in 10.3.x or 10.4.x on a clean install (Drupal standard profile). Do you have any custom modules installed? Or is everything well supported contrib modules?
Comment #4
claudiu.cristeaOn a clean install, with PHP 8.2.27 and 10.4.4, I cannot reproduce the issue. Please add more details about your installation.
It's very weird that that path of the code is taken with Drupal 10.4
Comment #5
jerrac commentedI just ran into this error message as well.
I think there is something in the ECA core module causing it. With ECA core enabled, the error occurs, without, it does not occur.
Drupal 10.4, CAS 3.0.0 beta 3. ECA 2.1.6 and 2.1.x-dev.
Is the Drupal\cas\DependencyInjection\DeprecatedEventConstants process method trying to get a list of deprecated events? As far as I can tell the ECA module has no deprecated events, so why would it somehow mess with CAS?
Does the closure on line 58 really need to return a string? Removing the ': string' makes the error go away. Though I haven't tested for what side effects that might have.
Comment #6
jrochate commentedCheck! I have also ECA enabled.
Comment #7
bkosborneComment #8
claudiu.cristeaOk, looks like a bug. I'm into it
Comment #10
jrochate commentedIt looks good to me.
I have patched, enabled the module on the same installation that the error occurred before, and cache can be cleaned without any warning nor error.
Thanks.
Comment #11
claudiu.cristea@jrochate, thank you for testing. However, now the tests are failing and I need to investigate this. Also, it would be good to get some input also from @jerrac
Comment #12
claudiu.cristea@jrochate @jerrac, could you test the latest version? I've made some changes compared to the first attempt.
Comment #13
jerrac commented@claudiu.cristea As far as I can tell that works. I switched to the CAS 3.x-dev branch and manually adjusted the
$eventNameslines to match$eventNames = array_map(fn(array $call): string => (string) $call[1][0], $definition->getMethodCalls());No WSODs or errors after making the change. If I revert the change, it errors.
So as long as the code is doing whatever else it is supposed to, then I think we're good. :)
Comment #14
claudiu.cristeaThank you. If you’ve tested and it’s working it would help to mark the issue as RTBC so that we can merge the changes and release a new version
Comment #15
jrochate commentedI'm testing against 3-beta3 and so far so good. no errors. marking RTBC
Comment #17
claudiu.cristeaThank you. Merged
Comment #18
claudiu.cristeaReleased in 3.0.0-beta4
Comment #19
claudiu.cristeaAdding credits