-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
Either explicitly define DBAL connections error with version 2.4.1 #1362
Comments
Look in all files. Have you checked prod/doctrine.yaml? |
I was in dev, no other file. And Prod :
|
In prod you need to use doctrine.dbal.connections too. Search for other such files, maybe you have more such files in dev too. |
It not suppose to be cascading? |
It was and this was always buggy with multiple connections, that's why we are fixing this by disallowing it. See #1356 for more info |
I copy the doctrine.yaml everywhere, plus add the prod difference to prod. But still have the error. |
I think broken thousands of application to fixe a few that don't understand the standard way of using symfony configuration is a bad idea. If there's a limitation (more a bug) in symfony config, there's we're it should be fixe. |
I have the same issue and was related to some dependency injection like this (which respect the config structure and should be valid configuration.):
|
I agree. this is a big BC who can be avoided. A better fix (to my point of view) would have been to drop simple configuration support and add deprecation message for who use it to force multiple configuration usage to avoid config confusion. This fix is braking more stuffs than it fix. |
@Webonaute I don't understand why the prepend extension config you are using triggers the exception in the title, IMO the structure is valid as you mentioned. It should work, and if it does not, that's what should be fixed, right? Can you please debug further? |
A reproducer project for any of these issues would be appreciated. |
I'm using SncRedisBundle for |
It might be related to doctrine configuration made through SncRedisBundle (then defining |
Please don't mix issues in here. snc_redis issue should go elsewhere, preferably to their bug tracker. This issue can happen only if configuration is processed twice. That can happen only if you have multiple doctrine configurations that have to be processed in same environment. Additionally, it can happen only if you have multiple connections/entity managers. |
@ostrolucky it's somehow related because @PhilETaylor is defining |
Again, here let's talk only about errors I have quoted before, please. You may put feedback about snc_redis somewhere else, but it sounds like snc_redis issue. But again, it's most likely unrelated to changes that triggered the quoted errors. |
ok its clear you are not interested in how your changes have broken production sites and the changes interaction with other projects. I have deleted my comments and will unsubscribe. Have fun. |
Please be sure we're all interested in feedbacks! |
I've setup a simple project to replicate the issue: https://github.com/NoodlesNZ/doctrine_config clone the repo and run |
I think the issue is that #1356 introduced an error rather than a deprecation |
It certainly had the desired effect of getting developer's attention. Given the project in my previous comment, how would we fix the |
Having similar issue. This happens when you inject custom entity managers via For me you should deprecate using simplified syntax or log a warning that it may cause issues. Alternatively just redo your flex recipe to come with all config keys so they can be overrode from 3rd party bundles. If you have any solution I'd like to hear because we planned new release for today and now we are blocked by this issue. |
Recipe comes with simplified/shortened configuration syntax for both files, doctrine.yaml and prod/doctrine.yaml. Changing it from shortened version in doctrine.yaml, but forgetting to do the same in prod/doctrine.yaml, or using different format somewhere else is exactly why we are throwing the error. It would be fine if it was without side effects, but that's not the case unfortunately and I am afraid lot of people don't realize this. And I don't see why it becomes impossible to define this via prependExtensionConfig anymore. It should be possible, you just need to use same format in prependExtensionConfig as you used in yaml files. And error was intentional as well. Deprecation is too weak and would mask legitimate issues that result from this combined approach. After all, this is also documented at https://symfony.com/doc/current/reference/configuration/doctrine.html#shortened-configuration-syntax :
So from my POV I'm just making sure documentation is correct. My choice was either error when using mixed approach with multiple ems/connections, or deprecation of whole shortened configuration. Deprecating whole shortened configuration would mean pretty much every application would have to go through this issue in doctrine-bundle 3.0 though, instead of only projects with multiple managers and mixed configurations, so we decided not to go with it. |
I'm afraid it's not possible because the doc states
So by providing shortened syntax in your recipe you pretty much killed all cases where 3rd party code would inject its own entity managers: $container->prependExtensionConfig('doctrine', [
'orm' => [
'entity_managers' => [],
],
]); This raises an error here: https://github.com/doctrine/DoctrineBundle/blob/2.4.x/DependencyInjection/Configuration.php#L416 Injecting entity managers is only possible if you remove or modify default config files but this is simply not possible for some projects. Ibexa DXP can be installed over existing Symfony applications. We no longer ship it as a "project" because we don't want to duplicate and maintain all the stuff coming from 3rd party bundles. |
Well, that's the issue. Bundles using
then release it as a major version, not as a minor one
You cannot use them at the same time in a single file. but different files could make different choices before.
Projects using mixed approach could still have a working configuration, and you broke BC for them. I think the all issues with mixed configuration actually come from the fact that the shortened configuration kept the name of the entity manager configurable, by rewriting the configuration based on the separate |
Btw, I don't even think #1356 actually fixes the issue when you use the shortened configuration with customized |
a BC issus like this should have had at least DEPRECATED status in this version, then change in a major version. And it seem that now we do have to put all doctrine configuration in one file, and take everything that come with others bundles (especially extensions one) into one file. That is breaking symfony way of doing stuff. |
No it's not. Now we CAN'T have any configuration coming from extensions bundles in separate config files. |
I think we should revert #1356 as a bugfix and reconsider the issue in light of the feedback we have here. |
@nicolas-grekas if you want my opinion, you should deprecate single configuration in this version and remove it in a major version. having a simple structure would help preventing merging wrong configuration structure. |
Blindly injecting doctrine configuration without considering what connections and entity managers did users configure is also the type of problem doctrine-bundle 2.4 solves. Unless those bundles define their own entity managers, they were broken already, IMHO. It just so happened that they were working for most users, because most users don't use multiple connections. I also wonder if these bundles consider the possibility users might need multiple bundles that use this prependExtensionConfig for configuring doctrine too...
We didn't do an API break. We simply started to reject invalid configuration. Adding a validation is not a BC break included under BC promise anywhere. Users relying on this is unfortunate, but that happens.
Unfortunately, documentation doesn't say so. It doesn't specify single file and that implies you cannot use them at the same time no matter 1 or multiple files. You and me know documentation probably really meant single file only, but average user really wouldn't deduct so after reading that. After all, given documentation link was sent to me by someone else.
Working doesn't mean correct. What's such example? In cases I see, it either doesn't make sense to use long/short syntax, or bundle was designed incorrectly because it never assumed user might have multiple entity managers.
We can't just document this mindfuck as a feature in doctrine-bundle 3. If there is no entity manager named default, we simply cannot be applying the change to new entity manager named default. For shortened configuration to work, default entity manager must be known. Otherwise this shortened configuration will be applied for wrong entity manager.
That might be true, but it's very unlikely to change name of default_entity_manager if you only use simplified config everywhere. That doesn't make sense. Additionally, users would notice such issue really quick, because such configuration from user's POV would not go in effect - they would notice since they have one entity manager only. Unlike when you have multiple entity managers and change will get applied to first one so you might think all others are fine too.
These are false, please don't spread FUD. Config files are still merged correctly, you just need to use same format everywhere. It actually makes expectations when configs are merged more clear and without side effects.
Reverting is always a last resort. If we are to revert this, I would like a plan before doing that. But only plan I see is to deprecate whole simplified config instead. Is that fine/preferred with you? |
Well, the fact that people don't actually change the name of the default entity manager when using the short config is wrong (based on the support I provided on IRC and then Slack over the years). |
But that was the issue in #1337. Doctrine-bundle is overriding user specified default_entity_manager with
Ok, I could live with this. So basically current check + count($entity_managers) > 1? Although bundles using prependExtension would still trigger the error if users use multiple entity managers... |
See #1368 |
@ostrolucky sorry, but it's looks like this limitation for mixed simple config is quite strange decision.. If we have configuration for tests, prod and dev we should have 3 configuration files with few lines difference... in most cases the configurations are complex, also there are other third party bundles which overrides parts of the configuration /add something/.. to disallow such override does not look as a legit solution. Don't get me wrong.. I understand the issues which this causes, but now we loose the configuration overriding option /which is quite flexible/. |
@netbull That's again FUD like the 2 other comments I quoted... Overrides stil work. When defining |
In my case, this happens having a wrong config key under prod/doctrine.yaml, without wrong key, no duplication is neccesary |
@ostrolucky I would not say that's FUD, but is reaction to the unclear error message out of nowhere after updating and some time debugging what the *** broke on the prod CI/CD pipeline.. However setting a dummy |
@ostrolucky Can we then add an empty |
@webhdx have you tried
? Your bundle probably never worked for users with multiple connections/entity managers correctly, did it? This issue at least alerted you to it. And yes I wish we used long format everywhere, so it's possible I'll deprecate short one in next minor instead. But recipe itself is not under my control. Although anyone can try to create a pull request for recipe proposing this. If nothing else, at least default production file would stop misleading people that configuration set there is applied to all entity managers. |
@NoodlesNZ I have cloned your project, and it shows a I would fix the first file like so: --- a/config/packages/prod/doctrine.yaml
+++ b/config/packages/prod/doctrine.yaml
@@ -1,15 +1,17 @@
doctrine:
orm:
auto_generate_proxy_classes: false
- metadata_cache_driver:
- type: pool
- pool: doctrine.system_cache_pool
- query_cache_driver:
- type: pool
- pool: doctrine.system_cache_pool
- result_cache_driver:
- type: pool
- pool: doctrine.result_cache_pool
+ entity_managers:
+ default:
+ metadata_cache_driver:
+ type: pool
+ pool: doctrine.system_cache_pool
+ query_cache_driver:
+ type: pool
+ pool: doctrine.system_cache_pool
+ result_cache_driver:
+ type: pool
+ pool: doctrine.result_cache_pool If I check with @Webonaute the screenshot you posted show that the |
This will be reverted in 2.4.2 that will be released shortly. I've reopened #1337 and we are waiting for ideas for fixing this there. IMO best would be to deprecate whole short syntax. |
Got "Either explicitly define DBAL connections in all doctrine-bundle configuration files, or in none of them." But looking at the changelog for 2.4.x I don't see anything that need to be change.
The text was updated successfully, but these errors were encountered: