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

Set doctrine.orm.entity_manager.abstract as lazy #559

Merged
merged 1 commit into from
Aug 10, 2016

Conversation

nicolas-grekas
Copy link
Member

@@ -95,7 +95,7 @@

<service id="doctrine.orm.configuration" class="%doctrine.orm.configuration.class%" abstract="true" public="false" />

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to set the attribute dynamically in the extension class depending on whether or not it is available.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea how you'd do that? This is purely an implementation detail that doesn't leak through the interfaces. Given that next versions are going to need this "lazy", adding the dynamic check would only be a micro optim for soon to be legacy versions. Worth it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to set the attribute dynamically in the extension class depending on whether or not it is available.

"lazy" is simply no-op if the required components aren't installed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @nicolas-grekas and @Ocramius. there is no need to make it conditional as it is already handled gracefully.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am okay with that too if you then update the min version for the DependencyInjection component instead.

@stof
Copy link
Member

stof commented Jul 25, 2016

you need to change the DI min dependency from 2.2 to 2.3 to fix the deps=low tests

@nicolas-grekas
Copy link
Member Author

@stof updated (line for DI added)

@kimhemsoe kimhemsoe merged commit dd40b0a into doctrine:master Aug 10, 2016
@kimhemsoe
Copy link
Member

Thanks @nicolas-grekas

@antanas-arvasevicius
Copy link

antanas-arvasevicius commented Aug 22, 2016

Hello,
I've noticed that this change will trigger exception in our project:
[Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException]
Circular reference detected for service "doctrine.dbal.default_connection",
path: "doctrine.dbal.default_connection".

We are using lazy:true in services.yml. Looks like your change is disabling other services which has lazy=true; Strange. Half of a day I'm searching for a problem, but can't find, maybe you could find why that happens. Could be bug in dependency container?
Thanks.

Test case:

services.yml:
  test:
    class: Test
    arguments: ['@doctrine.orm.default_entity_manager']
    lazy: true
    tags:
      - { name: doctrine.event_listener, event: prePersist }

test.php:

class Test
{
    public function __construct(EntityManager $em)
    {
    }
}
composer.json:
        "symfony/proxy-manager-bridge": "~2.3",
        "ocramius/proxy-manager": "~1.0",
        "symfony/symfony": "~2.8.9",

@kimhemsoe
Copy link
Member

@antanas-arvasevicius Could you repost in #559 for now. It may/may not be the same error, but for now it is nice to all the information in the same issue until we know more.

@antanas-arvasevicius
Copy link

Hello, what did you mean by repost in #559 as this thread is #559?

By my example error is clearly known, it's due circular dependency of entity manager in listener service, and that's why I've had made that listener as a lazy service.
But looks like this commit will break "lazy" support in the system. Or maybe DI won't allow lazy -> lazy -> lazy dependencies.

@kimhemsoe
Copy link
Member

Sorry i meant #562

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

Successfully merging this pull request may close these issues.

6 participants