-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Bridge/Doctrine] Reset the EM lazy-proxy instead of the EM service #19203
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
Conversation
bcfdac7
to
f5287aa
Compare
} | ||
$manager->setProxyInitializer( | ||
function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) { | ||
$this->container->set($name, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not solve the issue, as it is what will be deprecated
Status: needs work |
f5287aa
to
7444ccc
Compare
Updated |
358a6bf
to
6bfdb82
Compare
if (isset($this->aliases[$name = strtolower($name)])) { | ||
$name = $this->aliases[$name]; | ||
} | ||
$method = 'get'.strtr($name, $this->underscoreMap).'Service'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it possible instead to access the container methods map ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW i guess we should somehow deprecate using another container than the one provided by symfony ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method maps is now used also. We already are enforcing a symfony container, see type hint on ContainerAwareTrait::setContainer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course but the type hint is targeting the interface, and we can't know its internals.
2efb9d2
to
0315985
Compare
Implementation details & discussion following @Ener-Getick comments: the Yet, I think it's just fine to do direct access. Let's be pragmatic. |
@nicolas-grekas would be great to debug CI failures |
0315985
to
c112dc0
Compare
c112dc0
to
c581cd4
Compare
Thank you @nicolas-grekas. |
…he EM service (nicolas-grekas) This PR was merged into the 3.2-dev branch. Discussion ---------- [Bridge/Doctrine] Reset the EM lazy-proxy instead of the EM service | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | no | Fixed tickets | - | License | MIT | Doc PR | - This makes the entity manager resettable by resetting its proxy, which should be more robust than resetting its service. See first comments in #19192 Ping @stof Commits ------- c581cd4 [Bridge/Doctrine] Reset the EM lazy-proxy instead of the EM service
@nicolas-grekas you forgot the second half of this task: opening a PR on DoctrineBundle to mark the EM services as lazy so that a proxy is generated for them. |
How to set entity managers lazy by default doctrine configuration ? My conf : doctrine:
orm:
auto_generate_proxy_classes: "%kernel.debug%"
default_entity_manager: default
entity_managers:
sso:
connection: sso
mappings:
GsoiJNumAdminMainBundle:
type: "annotation"
dir: "Entity/SSO"
prefix: "MyPrefix\\Entity\\SSO" When i want to reset the manager, i got the deprecation message : with this code : $this->container->get('doctrine')->resetManager('sso'); |
install |
Thank you @stof for your explanation! |
This makes the entity manager resettable by resetting its proxy, which should be more robust than resetting its service.
See first comments in #19192
Ping @stof