Dear Community!

We have successfully upgraded our Acquia Lightning Project from 3.1.5 (Drupal 8.5.7) to the current newest version 3.200 (Drupal 8.6.1)

With that, we had to upgrade the Domain Site Settings Module to 1.3 with the patch from this issue
https://www.drupal.org/project/domain_site_settings/issues/2930391

Patch: https://www.drupal.org/files/issues/2018-08-16/2930391-16.patch

If we try to "drush cr" after this update we get the following error:

In Container.php line 141:
Circular reference detected for service "router.route_provider", path: "twig -> twig.extension -> url_generator -> router.route_provider -> path_processor_manager -> domain_source.path_processor -> domain.negotiator -> router -> router.no_access_checks".

But clearing cache in the backend fia the module "admin-toolbar" works fine though.

Versions:
Drush: 9.4
Domain: 1.0.0-alpha13
Domain Site Settings: 1.3

This functionality worked before the update.

Comments

kevin.pfeifer created an issue. See original summary.

giorgosk’s picture

Get the same (no lightning distribution)
Drush 8.1.16 or Drupal Console 1.8.0 report same error when running Cache rebuild
everything else seems to be working fine

kevin.pfeifer’s picture

Have done following updates but this problem still persists for me:

Drupal => 8.6.2 (through Lightning 8.x-3.2)
Drush => 9.5.2

kevin.pfeifer’s picture

Project: Domain Site Settings » Domain
Version: 8.x-1.3 » 8.x-1.x-dev

We tried disabling one module after another and found out, that the issue is not the "domain_site_settings" module. The problem still persisted.
Instead the error was "fixed" when we disabled "Domain Source" which is a submodule of the "Domain Access" module.
With that i have changed the Project from this issue to "Domain Access".

We already updated the following packages:
Domain: 1.0.0-alpha14
Domain-Site-Settings: 1.3

agentrickard’s picture

@kevin.pfeifer Thanks for validating that.

This isn't an error we run into in our automated testing, or that I can easily reproduce.

Granted, I'm using drush 8.1.12...

So do we think this is an issue that on ly occurs when using drush 9?

agentrickard’s picture

Status: Active » Postponed (maintainer needs more info)

Tested with drush 9.5.2 and no error.

> domain: drush --version
Drush Launcher Version: 0.6.0
Drush Commandline Tool 9.5.2
> domain: drush cr
 [success] Cache rebuild complete.
> domain: 

Looking for reliable steps to reproduce this issue.

criscom’s picture

Hi Ken,

thanks a lot for verifying this issue. We will try to give you reliable steps to reproduce this issue as soon as we can. The problem occurred after updating to Drupal 8.6.1 but this was not the issue. We'll get back to you when we have more information. Thanks.

Best,
Chris

kevin.pfeifer’s picture

We created a separat host with the same composer.json, theme files and custom modules but without the current present config.
On this new host, we are able to perform a drush cr successfully.

Therefore, as far is I can tell, it has to be a problem with the config/DB.

I currently try to step through the drush cr command to find out where this "Circular reference" starts to appear.

But i have noticed a rather "strange" behaviour.

In my opinion, the "drush cr" command should do the same as if i would write "drush cache:clear" and then all the available cache options.
When clearing each cache option individually, this "Circular reference" does not appear.

The options available are:

  1. drush
  2. theme-registry
  3. router
  4. css-js
  5. render
  6. plugin
  7. bin
  8. views
kevin.pfeifer’s picture

I have added a debug output to the docroot/core/lib/Drupal/Component/DependencyInjection/Container.php file in the get function to output the current $id before it throws the ServiceCircularReferenceException.

See here: https://screenshot.sunlime.at/1193159ac5bd9036a4c60fda71776c74

I did this on both my local machine (where the drush cr doesn't work) and the remote machine (where the drush cr works)

On the left side is the remote machine and on the right the local

https://screenshot.sunlime.at/a53e14edfcbbaf193cbce62c37950470
https://screenshot.sunlime.at/744835838c37da1dd2117ebb1ee875b2

As you can see, the "language_manager" is loaded earlier on the remote then on the local.

I guess in there the $this->loading array (which tells the Dependency Injection which other Modules/Classes to load in the Drupal\Component\DependencyInjection\Container Class) will be cleaned up.

But i have no idea where or how the language_manager is loaded in there.

I guess it has something to do with the DB/Config but i don't know where to start.

idebr’s picture

kevin.pfeifer’s picture

We have found a solution to our problem!

First of all we created a patch to change all the "domain.negotiator" implementations from the "default" Dependency Injection way to this notation:

\Drupal::service('domain.negotiator')

Patch is included down below (3005048-Domain_Source-circular_reference_for_router.route_provider.patch)

Now the error message has changed from

Circular reference detected for service "router.route_provider", path: "twig -> twig.extension -> url_generator -> router.route_provider -> path_processor_manager -> domain_source.path_processor -> domain.negotiator -> router -> router.no_access_checks".

to

Circular reference detected for service "router.route_provider", path: "twig -> twig.extension -> url_generator -> router.route_provider -> path_processor_manager -> domain_source.path_processor -> router -> router.no_access_checks". 

You see that the domain.negotiator is not present in the path anymore.

Now there is still the "strange" dependency from domain_source.path_processor -> router.

Through XDebug we found out, that domain_source.path_processor requires the LanguageNegotiationUserAdmin which therefore needs the router.

In the LanguageNegotiationUserAdmin Interface we configured, that we are detecting the interface language through the "Account administrator pages".
https://screenshot.sunlime.at/13dd8221074c7f08c691cd69fbb6a5e3

After applying the patch mentioned above and disabling this detection method the drush cr command worked again.

Special thanks to @drunken-monkey, who helped us debugging this problem and provided us this solution!

drunken monkey’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new5.7 KB

I don’t think the patch in #11 should actually be needed once you disable the “Account administrator pages” language negotiation?

Anyways, to maybe provide a bit more information: The attached patch might be a “fix” that could actually be committed to this module. The current code is of course not actually a bug per se, but as we see, under some conditions (in addition to the “Account administrator pages” language negotiation, the key was also having a module with a hook_entity_type_alter() implementation that requires \Drupal::config() – the Contact module (in Core) in this case) it can lead to a very-hard-to-debug problem that kills the whole site. So, adding this patch to the module should probably be considered – the code gets just a tiny bit “uglier”, perhaps, but functionality will be completely unchanged in normal cases, and it helps prevent this strange problem.

kevin.pfeifer’s picture

@drunken-monkey:

Indeed this patch with the mentioned deactivation of "Account administrator pages" in /admin/config/regional/language/detection solved this Circular reference problem for us.

Thank you!

criscom’s picture

Thanks drunken monkey. Great fix, very much appreciated!

agentrickard’s picture

Yeah, this is one of those bad edge cases where not using Dependency Injection might be proper. It will at least save us from having to hunt down hard to replicate bugs. We had to use the same approach in DomainConfigOverrider.

I'm just back from vacation. I'll try to spin up a test branch for this by end of week.

agentrickard’s picture

bijumon.ta’s picture

@agentrickard

I have this issue

Uncaught PHP Exception Symfony\\Component\\DependencyInjection\\Exception\\ServiceCircularReferenceException: "Circular reference detected for service "domain.negotiator", path: "options_request_listener -> router.route_provider -> path_processor_manager -> domain_source.path_processor -> domain.negotiator"." at /var/www/htdocs/xxxxx/core/lib/Drupal/Component/DependencyInjection/Container.php line 141,

Let me know whether this patch fix this issue

Neodork’s picture

#12 works for me, possibly also #16 but #16 does not apply to 1.0.0-alpha14, because the Drupal code style additions have not had a release yet.

Drush Version: 8.1.10
Drupal Core Version: 8.6.2
Domain Access version: 1.0.0-alpha14

Also when I revert drupal/core back to 8.5.6 there seems to be no exception thrown.

bijumon.ta’s picture

@drunken monkey/ @agentrickard

I am getting this error regularly

Uncaught PHP Exception Symfony\\Compone
nt\\DependencyInjection\\Exception\\ServiceCircularReferenceException: "Circular reference detected for service "domain.negotiator", path: "options_request_listener -> router.route_provider -> path_processor_manager -> domain_source.path_processor -> domain.negotiator"." at /var/www/html/xxx/core/lib/Drupal/Component/DependencyInjection/Container.php line 141

Please let me know #12 or #16 will fix this error. Its very urgent.

agentrickard’s picture

The patch in #16 should work fine.

agentrickard’s picture

Status: Needs review » Fixed
agentrickard’s picture

Status: Fixed » Closed (fixed)

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

mykola dolynskyi’s picture

  Circular reference detected for service "domain.route_provider", path: "twig -> twig.extension -> url_generator -> domain.route_provider -> path_processor_manager -> country_
path.  
  path_processor -> mymodule.main_service -> pathauto.generator -> pathauto.alias_uniquifier".

if comment 2 below then no error

  mymodule.main_service:
    class: Drupal\mymodule\MainService
    arguments: [
      '@entity_type.manager', 
      '@config.factory', 
      '@domain.negotiator', 
      '@language_manager', 
      #'@pathauto.generator',
      '@path_alias.manager',
      #'@pathauto.alias_uniquifier',
      '@token.entity_mapper',
      '@pathauto.alias_storage_helper',
      '@token',
      '@pathauto.alias_cleaner'
    ]