Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ERROR: Circular reference detected for:" instead of creating Service with array of strings as parameters #299

Closed
forgie1 opened this issue Nov 5, 2023 · 5 comments

Comments

@forgie1
Copy link

forgie1 commented Nov 5, 2023

Version: 3.1.8 (only)

Bug Description

Can not build Container, attempt to build it ends in:
ERROR: Circular reference detected for: ....

Steps To Reproduce

DiExtension::beforeCompile()
{
    $manager = $builder->getDefinition($this->prefix('manager'));
    $manager->setFactory(LazyEventManager::class, ['Plugins\Cms\Models\Admin\UserManager::onCheck' => ['some.event.subscriber.x']]);
}

Expected Behavior

Container generated with code:

public function createServiceSome__events__manager(): Some\Events\LazyEventManager
    {
        return new Some\Events\LazyEventManager(['Plugins\Cms\Models\Admin\UserManager::onCheck' => ['some.event.subscriber.x']]);
    }

Possible Solution

Version: 3.1.7 didn't have this problem of Circular Reference created by trying to convert string to Live service.

@dg
Copy link
Member

dg commented Nov 5, 2023

@dg
Copy link
Member

dg commented Nov 5, 2023

If it's supposed to generate this code:

return new Some\Events\LazyEventManager(['Plugins\Cms\Models\Admin\UserManager::onCheck' => ['some.event.subscriber.x']]);

then you're missing parentheses in the definition and it should be there:

$manager->setFactory(LazyEventManager::class, [['Plugins\Cms\Models\Admin\UserManager::onCheck' => ['some.event.subscriber.x']]]);

If the bug is something else, try creating a repository with a minimal example demonstrating the bug. Because I am not able to replicate it from the given example.

@forgie1
Copy link
Author

forgie1 commented Nov 5, 2023

Thank you for reply.

I found the problem was elsewhere:
Statement::getEntity() returned:

v 3.1.7 return value was string:
addEventSubscriber

v 3.81.8 return value is array:

array(2) {
  [0]=>
  object(Nette\DI\Definitions\Reference)#7783 (1) {
    ["value":"Nette\DI\Definitions\Reference":private]=>
    string(4) "self"
  }
  [1]=>
  string(18) "addEventSubscriber"
}

I didn't find it here: https://github.com/nette/di/releases/tag/v3.1.8.

So this Issue may be closed I guess, i fixed it in our DiExtension.

@dg
Copy link
Member

dg commented Nov 5, 2023

Yeah, right. That was a fix again for a different problem, but it's a fact that can cause incompatibility, sorry.

@forgie1
Copy link
Author

forgie1 commented Nov 5, 2023

Thank you

@forgie1 forgie1 closed this as completed Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants