Skip to content

[DependencyInjection] DoctrineBundle 1.6.2 upgrade to 1.6.4 throw circular reference error with multi lazy services. #19901

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

Closed
antanas-arvasevicius opened this issue Sep 10, 2016 · 1 comment

Comments

@antanas-arvasevicius
Copy link
Contributor

antanas-arvasevicius commented Sep 10, 2016

Hello,
DoctrineBundle have made a change ir orm.xml (added lazy=true):

 <service id="doctrine.orm.entity_manager.abstract" class="%doctrine.orm.entity_manager.class%" abstract="true" lazy="true" />

Now all my lazy services which are actually doctrine listeners stopped working (throws circular error).

After couple of hours of debugging I've found out a bug (hopefully) in PhpDumper.php hasReference method.

I've added a debugging echo lines in that method and saw these results:

hasReference: (doctrine.dbal.default_connection) , visited: doctrine.orm.default_listeners.attach_entity_listeners -> listener.event_logger -> doctrine.orm.default_entity_manager -> doctrine.orm.default_entity_manager.delegate (eq: false)
Service: doctrine.orm.default_entity_manager.delegate (lazy), has arguments: [ doctrine.dbal.default_connection, def: Doctrine\ORM\Configuration  ]
hasReference: (doctrine.dbal.default_connection) , visited: doctrine.orm.default_listeners.attach_entity_listeners -> listener.event_logger -> doctrine.orm.default_entity_manager -> doctrine.orm.default_entity_manager.delegate -> doctrine.dbal.default_connection (eq: true)

It looks like hasReference also recursively looking up a lazy services arguments for reference search,
I've thought, is that really logically? Because lazy services is lazy and are instantiated indirectly so more logically would be skip reference search in lazy service definitions, isn't it?

more information:
doctrine/DoctrineBundle#559 (comment)

@gxolin
Copy link

gxolin commented Sep 22, 2016

Thanks for the investigation, we're experiencing the same issue and forced doctrine-bundle 1.6.3 as a quick and dirty fix. Do you guys have a better workaround ?

fabpot added a commit that referenced this issue Dec 3, 2016
…n't search references in lazy service. (antanas-arvasevicius)

This PR was merged into the 2.7 branch.

Discussion
----------

[DependencyInjection] PhpDumper.php: hasReference() shouldn't search references in lazy service.

| Q | A |
| --- | --- |
| Branch? | 2.7 |
| Bug fix? | yes |
| New feature? | yes |
| BC breaks? | no |
| Tests pass? | yes |
| Fixed tickets | #19901 |
| License | MIT |
| Doc PR | N/A |

more info:
#19901

Commits
-------

595a978 [DependencyInjection] PhpDumper.php: hasReference() should not search references in lazy service arguments.
@fabpot fabpot closed this as completed Dec 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants