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

Fix configuration inheritance to not override default connection/EM values #1648

Merged
merged 2 commits into from Apr 21, 2023

Conversation

tucksaun
Copy link
Contributor

Hi there!

I recently unveiled a weird behavior when doing some cleanup on a project I work on.
Long story short, we have several connections, use a different name than default for the main one, and because we have config files defining only doctrine.dbal.types, the default_connection ends up being reset to default.

While trying to fix this I realized this is similar to #1337 (just another section of the config really), so I try to fix #1337 at the same time (therefore being an alternative to #1356).

The true nature of the fix is mostly not to run the custom pre-normalization process but then this makes the default empty configuration not work anymore.
So we move the side effect of this process (creating an empty 'default' connection configuration) out in the Extension and we rerun the normalization process again so that the default values for connections and entity manager get resolved properly.

This should be considered a bugfix, but I'm not really sure which branch to target in that case, let me know if you want me to rebase and target another branch instead

@tucksaun tucksaun force-pushed the fix-configuration-inheritance branch from 34af8c5 to d6dc672 Compare April 14, 2023 20:34
Copy link
Member

@ostrolucky ostrolucky left a comment

Choose a reason for hiding this comment

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

This was a can of worms last time, so I think I will need review from someone else as well.

Tests/DependencyInjection/DoctrineExtensionTest.php Outdated Show resolved Hide resolved
DependencyInjection/Configuration.php Outdated Show resolved Hide resolved
DependencyInjection/Configuration.php Outdated Show resolved Hide resolved
DependencyInjection/DoctrineExtension.php Outdated Show resolved Hide resolved
DependencyInjection/DoctrineExtension.php Show resolved Hide resolved
DependencyInjection/DoctrineExtension.php Outdated Show resolved Hide resolved
DependencyInjection/DoctrineExtension.php Outdated Show resolved Hide resolved
@tucksaun tucksaun force-pushed the fix-configuration-inheritance branch 2 times, most recently from a07c83d to 18874e1 Compare April 15, 2023 02:10
@tucksaun
Copy link
Contributor Author

This was a can of worms last time, so I think I will need review from someone else as well.

Yeah, I've read that 😞
I guess @nicolas-grekas and @stof would be great ones for reviewing this PR

…nection and default_entity_manager

This another take at fixing 1337 but also at dbal section that has the same issue with `default_connection`
@tucksaun tucksaun force-pushed the fix-configuration-inheritance branch from 18874e1 to 17bc9a3 Compare April 15, 2023 02:12
@tucksaun
Copy link
Contributor Author

@ostrolucky thank you for the review btw!
all comments (except dbalLoad/ormLoad) should have been addressed 💪

@stof
Copy link
Member

stof commented Apr 15, 2023

could we do the checks on default connection and default entity manager together at the beginning, to process the configuration only twice instead of 3 times ? Otherwise, we might report deprecations 3 times when a deprecated setting is used.

@ostrolucky ostrolucky added the Bug label Apr 15, 2023
@ostrolucky ostrolucky added this to the 2.9.2 milestone Apr 15, 2023
@tucksaun
Copy link
Contributor Author

Good call @stof !
We could then wrap this logic into processConfiguration. Wdyt?

@ostrolucky
Copy link
Member

Good idea I think

@tucksaun tucksaun force-pushed the fix-configuration-inheritance branch from 85f44de to f071a0a Compare April 18, 2023 21:45
Copy link
Contributor

@dmaicher dmaicher left a comment

Choose a reason for hiding this comment

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

LGTM and also tested it quickly on one of my apps: no issues 👍

@ostrolucky ostrolucky merged commit 1550341 into doctrine:2.9.x Apr 21, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

default_entity_manager config param is not inherited from parent config file
4 participants