Problem/Motivation

The config get in the constructor leads to a circular dependency injection error when used with Domain Config and the \Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin plugin from Drupal Core.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

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

webflo created an issue. See original summary.

mably’s picture

Hi @webflo, is this ready for merge?

On my side I haven't been able to reproduce the problem after enabling the LanguageNegotiationUserAdmin plugin.

It could be interesting to have a test for it, if it depends only on Core and some specific configuration.
To avoid reintroducing it later on.

Wondering if we shouldn't do the same for DomainPathHelper, what do you think?

mably’s picture

Status: Active » Needs review
webflo’s picture

@mably Thanks for looking into it. Here is the error with backtrace.

Modules/configuration needed to reproduce: LanguageNegotiationUserAdmin, domain_config (Version 2.0.0-rc1)

The website encountered an unexpected error. Try again later.

Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "router.route_provider", path: "options_request_listener -> router.route_provider -> path_processor_manager -> path_alias.path_processor -> domain_path.path_alias_manager -> router -> router.no_access_checks". in Drupal\Component\DependencyInjection\Container->get() (line 147 of core/lib/Drupal/Component/DependencyInjection/Container.php).

Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 237)
Drupal\Component\DependencyInjection\Container->createService() (Line: 177)
Drupal\Component\DependencyInjection\Container->get() (Line: 426)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 237)
Drupal\Component\DependencyInjection\Container->createService() (Line: 177)
Drupal\Component\DependencyInjection\Container->get() (Line: 93)
Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin::create() (Line: 21)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() (Line: 85)
Drupal\Component\Plugin\PluginManagerBase->createInstance() (Line: 225)
Drupal\language\LanguageNegotiator->getNegotiationMethodInstance() (Line: 197)
Drupal\language\LanguageNegotiator->negotiateLanguage() (Line: 137)
Drupal\language\LanguageNegotiator->initializeType() (Line: 225)
Drupal\language\ConfigurableLanguageManager->getCurrentLanguage() (Line: 455)
Drupal\domain_config\DomainConfigOverrider->initiateContext() (Line: 481)
Drupal\domain_config\DomainConfigOverrider->isDomainAvailable() (Line: 363)
Drupal\domain_config\DomainConfigOverrider->getCacheSuffix() (Line: 276)
Drupal\Core\Config\ConfigFactory->getCacheKeys() (Line: 295)
Drupal\Core\Config\ConfigFactory->getConfigCacheKey() (Line: 154)
Drupal\Core\Config\ConfigFactory->doLoadMultiple() (Line: 127)
Drupal\domain_config_ui\Config\ConfigFactory->doLoadMultiple() (Line: 104)
Drupal\Core\Config\ConfigFactory->doGet() (Line: 172)
Drupal\domain_config_ui\Config\ConfigFactory->doGet() (Line: 89)
Drupal\Core\Config\ConfigFactory->get() (Line: 88)
Drupal\domain_path\DomainPathAliasManager->__construct() (Line: 259)
Drupal\Component\DependencyInjection\Container->createService() (Line: 177)
Drupal\Component\DependencyInjection\Container->get() (Line: 426)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 237)
Drupal\Component\DependencyInjection\Container->createService() (Line: 177)
Drupal\Component\DependencyInjection\Container->get() (Line: 426)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 273)
Drupal\Component\DependencyInjection\Container->createService() (Line: 177)
Drupal\Component\DependencyInjection\Container->get() (Line: 426)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 237)
Drupal\Component\DependencyInjection\Container->createService() (Line: 177)
Drupal\Component\DependencyInjection\Container->get() (Line: 426)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() (Line: 237)
Drupal\Component\DependencyInjection\Container->createService() (Line: 177)
Drupal\Component\DependencyInjection\Container->get() (Line: 450)
Drupal\Component\DependencyInjection\Container->Drupal\Component\DependencyInjection\{closure}() (Line: 243)
mably’s picture

Do you mean that the current MR doesn't fix the problem?

Have you tried with Domain 3.x?
I couldn't reproduce the problem with Domain Config 3.x.

But if this issue's MR fixes the problem, can you give me an RTBC so I can merge it?

EDIT: haven't been able to reproduce it with Domain 2.x either.

webflo’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

  • mably committed 0c6b245b on 2.x authored by webflo
    fix: #3570992 Avoid config get in constructor
    
    By: webflo
    By: mably
    
mably’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @webflo, it's merged.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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