Calling ClassResolver::__construct without the $container argument is deprecated in drupal:10.3.0

Created on 7 August 2024, 4 months ago

Problem/Motivation

I'm using this module on Drupal 10.3.1 with these patches:

Issue #3420063: Error: Call to a member function getConfig() OverridesSectionStorage.php
https://www.drupal.org/files/issues/2024-03-29/layout_builder_st-call_to...
Issue #3069964 Argument 1 passed to Drupal.. must implement interface Drupal null https://www.drupal.org/files/issues/2019-07-24/isTranslation-null-given....

Recently I was debugging the site with xdebug in VSCode and got this exception:

Calling Drupal\Core\DependencyInjection\ClassResolver::__construct without the $container argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. 
See https://www.drupal.org/node/3419963

And I've found this is related to the code:
modules/contrib/layout_builder_st/src/DependencyInjection/ClassResolver.php

Steps to reproduce

Install the module on 10.3.1 with patches above.
Enable xdebug exception breakpoint and open the page using the Layout Builder

Proposed resolution

remove from layout_builder_st.services.yml

    calls:
      - [setContainer, ['@service_container']]
  # Override the class resolver to so that InlineBlockEntityOperations can be swapped to the extend version.
  class_resolver:
    class: Drupal\layout_builder_st\DependencyInjection\ClassResolver

It was planned that this module would be a temporary solution and related problems should be solved in 8.8, but now we are on 10.3.1 and they still exists, I mean this one issue:
Allow synced Layout override Translations: translating labels and inline blocks
https://www.drupal.org/project/drupal/issues/2946333 📌 Allow synced Layout override Translations: translating labels and inline blocks Needs work

Any suggestions? Should I use the patch from Issue #2946333 and disable "Layout Builder Symmetric Translations".

Or maybe you can release an updated version for 10.3.x?

🐛 Bug report
Status

Active

Component

Code

Created by

🇬🇪Georgia almador

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

Comments & Activities

  • Issue created by @almador
  • 🇬🇪Georgia almador

    Today I noticed that clearing caches shows this error:

    The website encountered an unexpected error. Try again later.
    Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "class_resolver", path: "string_translation -> string_translator.locale.lookup -> config.factory -> config.typed -> class_resolver -> entity_type.manager". in Drupal\Component\DependencyInjection\Container->get() (line 149 of core/lib/Drupal/Component/DependencyInjection/Container.php).
    Drupal\Component\DependencyInjection\Container->get('class_resolver', 1) (Line: 438)
    Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 239)
    Drupal\Component\DependencyInjection\Container->createService(Array, 'entity_type.manager') (Line: 179)
    Drupal\Component\DependencyInjection\Container->get('entity_type.manager') (Line: 315)
    Drupal::entityTypeManager() (Line: 218)
    Drupal\Core\Session\AccountProxy->loadUserEntity('185') (Line: 77)
    Drupal\Core\Session\AccountProxy->getAccount() (Line: 121)
    Drupal\Core\Session\AccountProxy->hasPermission('access devel information') (Line: 200)
    backtrace_error_handler(16384, 'Calling Drupal\Core\DependencyInjection\ClassResolver::__construct without the $container argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3419963', '/home/user/public_html/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php', 23)
    trigger_error('Calling Drupal\Core\DependencyInjection\ClassResolver::__construct without the $container argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3419963', 16384) (Line: 23)
    Drupal\Core\DependencyInjection\ClassResolver->__construct() (Line: 261)
    Drupal\Component\DependencyInjection\Container->createService(Array, 'class_resolver') (Line: 179)
    Drupal\Component\DependencyInjection\Container->get('class_resolver', 1) (Line: 438)
    Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 239)
    Drupal\Component\DependencyInjection\Container->createService(Array, 'config.typed') (Line: 179)
    Drupal\Component\DependencyInjection\Container->get('config.typed', 1) (Line: 438)
    Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 239)
    Drupal\Component\DependencyInjection\Container->createService(Array, 'config.factory') (Line: 179)
    Drupal\Component\DependencyInjection\Container->get('config.factory', 1) (Line: 438)
    Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 239)
    Drupal\Component\DependencyInjection\Container->createService(Array, 'string_translator.locale.lookup') (Line: 179)
    Drupal\Component\DependencyInjection\Container->get('string_translator.locale.lookup', 1) (Line: 438)
    Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 275)
    Drupal\Component\DependencyInjection\Container->createService(Array, 'string_translation') (Line: 179)
    Drupal\Component\DependencyInjection\Container->get('string_translation') (Line: 197)
    Drupal::service('string_translation') (Line: 104)
    Drupal\Core\EventSubscriber\FinalExceptionSubscriber->getStringTranslation() (Line: 71)
    Drupal\Core\EventSubscriber\FinalExceptionSubscriber->t('The website encountered an unexpected error. Try again later.') (Line: 129)
    Drupal\Core\EventSubscriber\FinalExceptionSubscriber->onException(Object, 'kernel.exception', Object)
    call_user_func(Array, Object, 'kernel.exception', Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.exception') (Line: 239)
    Symfony\Component\HttpKernel\HttpKernel->handleThrowable(Object, Object, 1) (Line: 91)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    

    Any suggestions?

  • 🇩🇪Germany Grevil

    I synchronized the "class_resolver" service with the core "class_resolver" service in 📌 Automated Drupal 11 compatibility fixes for layout_builder_st Needs review , which fixed the issue!

  • 🇬🇪Georgia almador

    Hi, @grevil!

    Maybe you could provide the final patch to solve the error?

    Or prepare the more detailed instructions?

Production build 0.71.5 2024