Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "form_mode.manager", path: "form_mode.manager -> domain.negotiator". in drupal-8.5.6/html/core/lib/Drupal/Component/DependencyInjection/Container.php:141 Stack trace:

#0 drupal-8.5.6/html/modules/contrib/form_mode_manager/src/EntityTypeInfo.php(59): Drupal\Component\DependencyInjection\Container->get('form_mode.manag...')

#1 drupal-8.5.6/html/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php(28): Drupal\form_mode_manager\EntityTypeInfo::create(Object(Drupal\Core\DependencyInjection\Container))

#2 drupal-8.5.6/html/modules/contrib/form_mode_manager/form_mode_manager.module(26): Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition('Drupal\\form_mod...') #3

drupal-8.5.6/html/core/lib/Drupal/Core/Entity/EntityTypeManager.php(112): form_mode_manager_entity_type_build(Array)

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

SocialNicheGuru created an issue. See original summary.

woprrr’s picture

Status: Active » Postponed (maintainer needs more info)

Hi @SocialNicheGuru,

Are you using Domain access or Domain module in your stack ? This module seem's to have somes problems with others plugins over the contributed modules.

If Not can you describe more specifically your problem ? Modules installed / Reproduction path ?

EDIT : @SEE : https://www.drupal.org/project/domain_site_settings/issues/2930391#comme...

socialnicheguru’s picture

removed domain from my setup so no longer can test this.

woprrr’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Domain seem's to having lot of problems with the service container... In FMM case the EntityTypeInfo service are implemented as core use her proper EntityTypeInfo object too with injection of manager. I think this error can't be due to FMM if that error was fired by plugins that can be possible because plugins are instanciated a lot in DP 8 but in entityTypeInfo that only on reconstruct of Entity types (after clear cache by example).

I close this issue but if you can reproduce again we can try to instanciate manager statically with \Drupal::services('xxxxx') instead of usage of injection system (BAD). \o/

dj1999’s picture

Status: Closed (cannot reproduce) » Needs work

I use domain module and could reproducing.
After drush updb get this message:

In Container.php line 248:
                                                                                                                
  [Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException]                           
  Circular reference detected for service "form_mode.manager", path: "form_mode.manager -> form_mode.manager".  
                                                                                                                

Exception trace:
  at /var/www/html/vendor/symfony/dependency-injection/Container.php:248
 Symfony\Component\DependencyInjection\Container->make() at /var/www/html/vendor/symfony/dependency-injection/Container.php:231
 Symfony\Component\DependencyInjection\Container->get() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:580
 Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:558
 Symfony\Component\DependencyInjection\ContainerBuilder->get() at /var/www/html/www/modules/contrib/form_mode_manager/src/EntityTypeInfo.php:59
 Drupal\form_mode_manager\EntityTypeInfo::create() at /var/www/html/www/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php:28
 Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() at /var/www/html/www/modules/contrib/form_mode_manager/form_mode_manager.module:28
 form_mode_manager_entity_type_build() at /var/www/html/www/core/lib/Drupal/Core/Entity/EntityTypeManager.php:122
 Drupal\Core\Entity\EntityTypeManager->findDefinitions() at /var/www/html/www/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php:175
 Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() at /var/www/html/www/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryCachedTrait.php:22
 Drupal\Core\Plugin\DefaultPluginManager->getDefinition() at /var/www/html/www/core/lib/Drupal/Core/Entity/EntityTypeManager.php:136
 Drupal\Core\Entity\EntityTypeManager->getDefinition() at /var/www/html/www/core/lib/Drupal/Core/Entity/EntityTypeManager.php:257
 Drupal\Core\Entity\EntityTypeManager->getHandler() at /var/www/html/www/core/lib/Drupal/Core/Entity/EntityTypeManager.php:196
 Drupal\Core\Entity\EntityTypeManager->getStorage() at /var/www/html/www/modules/contrib/domain/domain/src/DomainNegotiator.php:230
 Drupal\domain\DomainNegotiator->domainStorage() at /var/www/html/www/modules/contrib/domain/domain/src/DomainNegotiator.php:180
 Drupal\domain\DomainNegotiator->negotiateActiveHostname() at /var/www/html/www/modules/contrib/domain/domain/src/DomainNegotiator.php:147
 Drupal\domain\DomainNegotiator->negotiateActiveDomain() at /var/www/html/www/modules/contrib/domain/domain/src/DomainNegotiator.php:157
 Drupal\domain\DomainNegotiator->getActiveDomain() at /var/www/html/www/modules/contrib/domain/domain_config/src/DomainConfigOverrider.php:238
 Drupal\domain_config\DomainConfigOverrider->initiateContext() at /var/www/html/www/modules/contrib/domain/domain_config/src/DomainConfigOverrider.php:120
 Drupal\domain_config\DomainConfigOverrider->loadOverrides() at /var/www/html/www/core/lib/Drupal/Core/Config/ConfigFactory.php:209
 Drupal\Core\Config\ConfigFactory->loadOverrides() at /var/www/html/www/core/lib/Drupal/Core/Config/ConfigFactory.php:169
 Drupal\Core\Config\ConfigFactory->doLoadMultiple() at /var/www/html/www/modules/contrib/domain/domain_config_ui/src/Config/ConfigFactory.php:68
 Drupal\domain_config_ui\Config\ConfigFactory->doLoadMultiple() at /var/www/html/www/core/lib/Drupal/Core/Config/ConfigFactory.php:104
 Drupal\Core\Config\ConfigFactory->doGet() at /var/www/html/www/modules/contrib/domain/domain_config_ui/src/Config/ConfigFactory.php:109
 Drupal\domain_config_ui\Config\ConfigFactory->doGet() at /var/www/html/www/core/lib/Drupal/Core/Config/ConfigFactory.php:89
 Drupal\Core\Config\ConfigFactory->get() at /var/www/html/www/modules/contrib/form_mode_manager/src/FormModeManager.php:305
 Drupal\form_mode_manager\FormModeManager->setFormModesToExclude() at /var/www/html/www/modules/contrib/form_mode_manager/src/FormModeManager.php:80
 Drupal\form_mode_manager\FormModeManager->__construct() at n/a:n/a
 ReflectionClass->newInstanceArgs() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:1144
 Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:618
 Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:558
 Symfony\Component\DependencyInjection\ContainerBuilder->get() at /var/www/html/www/modules/contrib/form_mode_manager/src/EntityTypeInfo.php:59
 Drupal\form_mode_manager\EntityTypeInfo::create() at /var/www/html/www/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php:28
 Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() at /var/www/html/www/modules/contrib/form_mode_manager/form_mode_manager.module:28
 form_mode_manager_entity_type_build() at /var/www/html/www/core/lib/Drupal/Core/Entity/EntityTypeManager.php:122
 Drupal\Core\Entity\EntityTypeManager->findDefinitions() at /var/www/html/www/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php:175
 Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() at /var/www/html/www/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryCachedTrait.php:22
 Drupal\Core\Plugin\DefaultPluginManager->getDefinition() at /var/www/html/www/core/lib/Drupal/Core/Entity/EntityTypeManager.php:136
 Drupal\Core\Entity\EntityTypeManager->getDefinition() at /var/www/html/www/core/lib/Drupal/Core/Entity/EntityTypeManager.php:257
 Drupal\Core\Entity\EntityTypeManager->getHandler() at /var/www/html/www/core/lib/Drupal/Core/Entity/EntityTypeManager.php:196
 Drupal\Core\Entity\EntityTypeManager->getStorage() at /var/www/html/www/modules/contrib/config_split/src/Plugin/ConfigFilter/SplitFilterDeriver.php:50
 Drupal\config_split\Plugin\ConfigFilter\SplitFilterDeriver::create() at /var/www/html/www/core/lib/Drupal/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecorator.php:25
 Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator->getDeriver() at /var/www/html/www/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php:99
 Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives() at /var/www/html/www/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php:87
 Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() at /var/www/html/www/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php:284
 Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() at /var/www/html/www/modules/contrib/config_filter/src/Plugin/ConfigFilterPluginManager.php:70
 Drupal\config_filter\Plugin\ConfigFilterPluginManager->findDefinitions() at /var/www/html/www/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php:175
 Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() at /var/www/html/www/modules/contrib/config_filter/src/Plugin/ConfigFilterPluginManager.php:37
 Drupal\config_filter\Plugin\ConfigFilterPluginManager->getFiltersForStorages() at /var/www/html/www/modules/contrib/config_filter/src/ConfigFilterStorageFactory.php:88
 Drupal\config_filter\ConfigFilterStorageFactory->getFilteredStorage() at /var/www/html/www/modules/contrib/config_filter/src/ConfigFilterStorageFactory.php:54
 Drupal\config_filter\ConfigFilterStorageFactory->getSync() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:1132
 Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:618
 Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:1267
 Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:1215
 Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:1117
 Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:618
 Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:1267
 Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:1215
 Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:1623
 Symfony\Component\DependencyInjection\ContainerBuilder->callMethod() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:1169
 Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:618
 Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php:558
 Symfony\Component\DependencyInjection\ContainerBuilder->get() at /var/www/html/vendor/drush/drush/src/Boot/DrupalBoot8.php:280
 Drush\Boot\DrupalBoot8->addDrupalModuleDrushCommands() at /var/www/html/vendor/drush/drush/src/Boot/DrupalBoot8.php:246
 Drush\Boot\DrupalBoot8->bootstrapDrupalFull() at /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php:293
 Drush\Boot\BootstrapManager->doBootstrap() at /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php:447
 Drush\Boot\BootstrapManager->bootstrapToPhaseIndex() at /var/www/html/vendor/drush/drush/src/Boot/BootstrapManager.php:396
 Drush\Boot\BootstrapManager->bootstrapToPhase() at /var/www/html/vendor/drush/drush/src/Boot/BootstrapHook.php:28
 Drush\Boot\BootstrapHook->initialize() at /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:44
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->doInitializeHook() at /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:36
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook() at /var/www/html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:29
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initialize() at /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php:145
 Consolidation\AnnotatedCommand\CommandProcessor->initializeHook() at /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:298
 Consolidation\AnnotatedCommand\AnnotatedCommand->initialize() at /var/www/html/vendor/symfony/console/Command/Command.php:221
 Symfony\Component\Console\Command\Command->run() at /var/www/html/vendor/symfony/console/Application.php:1027
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/console/Application.php:273
 Symfony\Component\Console\Application->doRun() at /var/www/html/vendor/symfony/console/Application.php:149
 Symfony\Component\Console\Application->run() at /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php:118
 Drush\Runtime\Runtime->doRun() at /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php:48
 Drush\Runtime\Runtime->run() at /var/www/html/vendor/drush/drush/drush.php:72
 require() at /var/www/html/vendor/drush/drush/drush:4
kekkis’s picture

I ran into the same issue upon upgrading from drush 10.3.6 to something newer that would let me get rid of migrate_tools. I tried with version 10.6.2 and 11.1.1 and the results were identical.

But: when I uninstall either domain_config (with domain_config_ui) or form_mode_manager, the problem goes away and running drush updb works again without problems. The problem here being that I'm not really keen on replacing either of the modules in this project. Any further digging into this would be greatly appreciated.

hartsak’s picture

Having the same problem as kekkis above.
Circular reference detected for service "form_mode.manager", path: "form_mode.manager -> form_mode.manager".

This happens when running
drush updb
after updating drush to 10.6.2 (same problem with drush 11.3.2). Also, php is updated to 8.1.

I managed to track the issue down to this file: form_mode_manager/src/FormModeManager.php

If I comment out the last row from the constructor

  public function __construct(EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory, EntityDisplayRepositoryInterface $entity_display_repository, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityRoutingMapManager $plugin_routes_manager) {
    $this->entityTypeManager = $entity_type_manager;
    $this->configFactory = $config_factory;
    $this->entityDisplayRepository = $entity_display_repository;
    $this->entityTypeBundleInfo = $entity_type_bundle_info;
    $this->entityRoutingMap = $plugin_routes_manager;
    //$this->setFormModesToExclude();
  }

"drush updb" works.

And in the setFormModesToExclude() method the problem seems to be this part

$config = $this->configFactory->get('form_mode_manager.settings')
      ->get('form_modes');

I also tested this in a clean project by just enabling both Form Mode Manager and domain_config. After that running "drush updb" causes the "Circular reference" error.

Any chance to get this fixed somehow? Uninstalling form mode manager or domain config in my project doesn't seem like a viable option right now and I need to have php & drush updated too.

scott_euser made their first commit to this issue’s fork.

scott_euser’s picture

Version: 8.x-2.0-rc1 » 8.x-2.x-dev
Status: Needs work » Needs review

Thanks for the tip in #7 - helped me get to the bottom of this. Having the constructor prepare the form modes to exclude is causing the circular reference when an update script is run that changes the modules list configuration such as captcha_update_8906. Moving the prep of which form modes to exclude to be called on demand when its first needed solves this.

scott_euser’s picture

Title: Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "form_mode.manager", path: "form_mode.manager -> domain.negotiator" » Service form_mode.manager causes a circular reference in particular scenarios
dinazaur’s picture

Status: Needs review » Reviewed & tested by the community

I had a similar issue the error was "... path: "form_mode.manger > config_split.cli > config.storage.sync

Applied a patch from the MR and it fixed the issue, hence I'm marking the issue as RTBC.

hartsak’s picture

Tested the fix in a clean project and it works. Thanks @scott_euser for the fix!

dww made their first commit to this issue’s fork.

dww’s picture

Cool, looks good. Thanks! I don't really want to mess with trying to add an automated test for this. Committed and pushed to 8.x-2.x.

p.s. Saving credit to hartsak and dinazaur for reviews + testing.

dww’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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