drupalextension icon indicating copy to clipboard operation
drupalextension copied to clipboard

Circular reference detected for Drupal::service('url_generator')

Open ivangrozni opened this issue 3 years ago • 3 comments

I'm having issues debugging a php error that is only thrown during behat testing. If I try to load url_generator service during behat step definition I'm getting this error and the tests are ultimately failing.

Circular reference detected for service "url_generator", path: "url_generator". (Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException)

I was able to get all other services service I tried, looks like url_generator is the only exception. If I check:

$c = \Drupal::genContainer();
$c->hasService('url_generator');
=> bool(true)
$c->initialized('url_generator');
=> bool(false)
$c->get('url_generator');
=> Circular reference detected for service "url_generator", path: "url_generator". (Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException)

This error only started after I've updated to php8.1. I can not even reproduce if I run it within drush php console (I can get url_generator service normally).

The other url_generator service issue I see during behat execution is:

Type error: Drupal\Core\Routing\UrlGenerator::setContext(): Argument #1 ($context) must be of type Symfony\Component\Routing\RequestContext, null given (Behat\Testwork\Call\Exception\FatalThrowableError)

They are probably related somehow, not sure.

Any idea where could the error be?

ivangrozni avatar Jun 21 '22 14:06 ivangrozni

That should be fixed with the latest Drupal driver version

Berdir avatar Jun 21 '22 16:06 Berdir

@Berdir Thanks for response. I'll test it out

ivangrozni avatar Jun 28 '22 10:06 ivangrozni

After php8.1 update faced the same. Updating drupal/drupal-extension with all dependencies solved the problem

mostepaniukvm avatar Sep 13 '22 16:09 mostepaniukvm