TypeError: Drupal\cas\DependencyInjection\DeprecatedEventConstants

Created on 18 March 2025, about 1 month ago

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

πŸ› Bug report
Status

Active

Version

3.0

Component

CAS

Created by

πŸ‡΅πŸ‡ΉPortugal jrochate

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

Merge Requests

Comments & Activities

  • Issue created by @jrochate
  • πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

    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?

  • πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

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

  • πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

    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 those path of the code is taken with Drupal 10.4

  • πŸ‡ΊπŸ‡ΈUnited States jerrac

    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.

  • πŸ‡΅πŸ‡ΉPortugal jrochate

    Check! I have also ECA enabled.

  • πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA
  • πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

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

  • πŸ‡΅πŸ‡ΉPortugal jrochate

    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.

  • πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

    @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

  • πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

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

  • πŸ‡ΊπŸ‡ΈUnited States jerrac

    @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. :)

  • πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

    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

  • πŸ‡΅πŸ‡ΉPortugal jrochate

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

  • Pipeline finished with Skipped
    17 days ago
    #467745
  • πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

    Thank you. Merged

  • πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

    Released in 3.0.0-beta4

  • πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

    Adding credits

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

Production build 0.71.5 2024