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

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

jrochate created an issue. See original summary.

bkosborne’s picture

I 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?

claudiu.cristea made their first commit to this issue’s fork.

claudiu.cristea’s picture

Version: 3.0.0-beta2 » 3.x-dev
Status: Active » Postponed (maintainer needs more info)

On 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

jerrac’s picture

I just ran into this error message as well.

Uncaught PHP Exception TypeError: "Drupal\\cas\\DependencyInjection\\DeprecatedEventConstants::Drupal\\cas\\DependencyInjection\\{closure}(): Return value must be of type string, Symfony\\Component\\DependencyInjection\\Reference returned" at /var/www/web/modules/contrib/cas/src/DependencyInjection/DeprecatedEventConstants.php line 58

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.

jrochate’s picture

Check! I have also ECA enabled.

bkosborne’s picture

Status: Postponed (maintainer needs more info) » Active
claudiu.cristea’s picture

Assigned: Unassigned » claudiu.cristea

Ok, looks like a bug. I'm into it

jrochate’s picture

Status: Active » Reviewed & tested by the community

It 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.

claudiu.cristea’s picture

Status: Reviewed & tested by the community » Needs work

@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

claudiu.cristea’s picture

Assigned: claudiu.cristea » Unassigned
Status: Needs work » Needs review

@jrochate @jerrac, could you test the latest version? I've made some changes compared to the first attempt.

jerrac’s picture

@claudiu.cristea As far as I can tell that works. I switched to the CAS 3.x-dev branch and manually adjusted the $eventNames lines 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. :)

claudiu.cristea’s picture

Thank 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

jrochate’s picture

Status: Needs review » Reviewed & tested by the community

I'm testing against 3-beta3 and so far so good. no errors. marking RTBC

  • claudiu.cristea committed 8ee1a86c on 3.x
    Issue #3513857 by claudiu.cristea, jrochate, jerrac: TypeError: Drupal\...
claudiu.cristea’s picture

Status: Reviewed & tested by the community » Fixed

Thank you. Merged

claudiu.cristea’s picture

Released in 3.0.0-beta4

claudiu.cristea’s picture

Adding credits

Status: Fixed » Closed (fixed)

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