Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DoctrineBridge] always load event listeners lazy via ServiceLocator #27675

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

Merged
merged 1 commit into from
Jun 28, 2018

Conversation

dmaicher
Copy link
Contributor

@dmaicher dmaicher commented Jun 21, 2018

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes/no
Tests pass? yes
Fixed tickets #27661
License MIT
Doc PR symfony/symfony-docs#9973

As described in #27661 this PR suggests to always load doctrine event listeners lazily from a service locator instead of the full service container.

If we agree to move forward I could tackle the remaining todos:

  • update UPGRADE.md
  • documentation PR
  • tested on real app

@weaverryan
Copy link
Member

I really think there is no downside - this pattern is followed in many other places in Symfony. The lazy flag was added SO long ago, I think it was basically an old work around before we had the proper service locator solution.

I’d say, move forward with the deprecation and upgrade log stuff. Then we’ll probably need Nicolas to double check the implementation (it makes sense to me - but this is his area).

And thanks for making a PR - what an awesome surprise!

@chalasr
Copy link
Member

chalasr commented Jun 25, 2018

deprecation notice for the lazy attribute sounds good to me.

@dmaicher
Copy link
Contributor Author

@weaverryan @chalasr but technically I removed the usage of the flag already 😄 So is a deprecation still correct? It should say something like The "lazy" attribute was removed in Symfony 4.2. Listeners are now always lazy by default.?

Or should we keep using the flag and remove it completely in 5.0? Although I think it does not have any BC breaks. Unless someone is weirdly relying on the fact that a service is eagerly instantiated 😋

@chalasr
Copy link
Member

chalasr commented Jun 26, 2018

I think going always lazy now is fine, the deprecation notice would only allow people to remove a dead tag attribute, and stop being triggered in 5.0. Not sure we had a similar case in the past so having an additional opinion would be good

@nicolas-grekas
Copy link
Member

By not triggering any depreciation for the unused "lazy" attribute, we're making it easier for e.g. bundles to support several major versions, isn't it? So should stay as is then IMHO.

@dmaicher
Copy link
Contributor Author

@nicolas-grekas haha ok. I just added the deprecation 😄 But I can remove it again if needed. No problem.

@weaverryan
Copy link
Member

So, would we keep that lazy flag (after it does nothing) forever? You’re right about compat, but keeping it forever seems odd.

@nicolas-grekas
Copy link
Member

We should just ignore it.

@dmaicher
Copy link
Contributor Author

Documentation PR added, deprecation notice removed, tested with a real Symfony app.

Ready for a last round of reviews 😊

@fabpot
Copy link
Member

fabpot commented Jun 28, 2018

Thank you @dmaicher.

@fabpot fabpot merged commit 130ec05 into symfony:master Jun 28, 2018
fabpot added a commit that referenced this pull request Jun 28, 2018
…ServiceLocator (dmaicher)

This PR was squashed before being merged into the 4.2-dev branch (closes #27675).

Discussion
----------

[DoctrineBridge] always load event listeners lazy via ServiceLocator

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes/no
| Tests pass?   | yes
| Fixed tickets | #27661
| License       | MIT
| Doc PR        | symfony/symfony-docs#9973

As described in #27661 this PR suggests to always load doctrine event listeners lazily from a service locator instead of the full service container.

If we agree to move forward I could tackle the remaining todos:

- [x] update UPGRADE.md
- [x] documentation PR
- [x] tested on real app

Commits
-------

130ec05 [DoctrineBridge] always load event listeners lazy via ServiceLocator
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Jun 29, 2018
…Symfony 4.2 change (dmaicher, javiereguiluz)

This PR was merged into the master branch.

Discussion
----------

[DoctrineBridge] update doctrine event listeners doc for Symfony 4.2 change

See symfony/symfony#27675.

Doctrine entity listeners are always lazily instantiated as of Symfony 4.2.

Commits
-------

4409fd6 Explain that lazy listeners are mandatory, not default
b56ef9e Update event_listeners_subscribers.rst
d8bb849 Reworded and added the versionadded directive
601450e Update event_listeners_subscribers.rst
@nicolas-grekas nicolas-grekas removed this from the next milestone Nov 1, 2018
@nicolas-grekas nicolas-grekas added this to the 4.2 milestone Nov 1, 2018
This was referenced Nov 3, 2018
@dmaicher dmaicher deleted the issue-27661 branch November 30, 2018 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants