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

Avoid loading of all manager services on getAliasNamespace function call #499

Closed
wants to merge 1 commit into from

Conversation

chiriacbogdan
Copy link

Every time someone writes AcmeDemoBundle:SomeEntity instead of Acme\DemoBundle\Entity\SomeEntity the function getAliasNamespace is called witch loads all entity manager services currently configured which initializes a connection to the database even if it is not necessary.

@kimhemsoe
Copy link
Member

I see the problem, but this is not the way to fix it.
To fix the problem you have, i suggest you try specify what version of database you are using. This should fix the issue where dbal connects to autodetect the db version.

@kimhemsoe
Copy link
Member

Closing for now.

@kimhemsoe kimhemsoe closed this Feb 18, 2016
@mihai-stancu
Copy link

@kimhemsoe the PR provides a way to avoid an unexpected (unwanted?) side effect of particular action. Is there a reason why this unexpected side effect would in fact be wanted?

More clearly: is there a reason why getAliasNamespace($alias) should trigger the initialization of all managers (and generate connections and autodetect versions etc.)?

If not then IMHO this PR is the way to fix the problem. Specifying the mysql version in your configuration seems like a cumbersome workaround.

+1 for this fix.

@kimhemsoe
Copy link
Member

The PR fixes nothing, it just add a new problem, which is, now we are depending on what order the managers are registered.
Lets say you have A and B. Now you add C and you start to see this error, that is not really nice and can lead to weird "ohh yeah.. you just need to change the bundle ordering or something.. comments"
We do not do not want that, we rather want to fail from the beginning so people understand the issue correct the first time.

Some dbal drivers need to connect to the database if someone is asking of the platform. I am guessing that that is the issue we have here. I do not know what is using the platform this early and it may even only be a issue while developing and not with caches enabled.

No, loading everything just to read a string from the config is not perfect. But it is not that easy to fix i believe.

Specifying the db version is not bad idea and it is not much more different then you need to tell doctrine what driver you want to use. It fixes alot of other problems too, like creation of database and etc. It also have the nice side effect that it is faster then auto detecting and you may even avoid connecting to the database if you do not do a query.

@kimhemsoe kimhemsoe reopened this Feb 19, 2016
@kimhemsoe kimhemsoe closed this Jun 21, 2016
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.

None yet

3 participants