Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DoctrineBridge] Fix automapping #44987

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
Jan 26, 2022
Merged

Conversation

mbabker
Copy link
Contributor

@mbabker mbabker commented Jan 12, 2022

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #44355
License MIT
Doc PR N/A

This should fix the broken automapping configuration for bundles that use annotations and attributes, see #44355 for additional details.

When using the newer bundle directory structure conventions, especially with the Bundle::getPath() method overridden to point the bundle root path to the Bundle class' parent directory, the issue comes up because the bundle filesystem root path does not match the root path for the actual bundle code (effectively the PSR-4 root path).

To fix automapping, the AbstractDoctrineExtension::detectMetadataDriver() method will be called a second time with the Bundle classpath if the first call (which is effectively the same as Bundle::getPath()) can't resolve the appropriate mapping type. This will also update setting $bundleConfig['dir'] for drivers that are based on PHP classes so that the root path is based on the bundle classpath (AKA the PSR-4 root path) instead of the bundle path.

The bulk of this patch is mainly from adding test fixture bundles to be able to test the AbstractDoctrineExtension::getMappingDriverBundleConfigDefaults() method in this repo and ensuring that the metadata driver detection works right for all of the supported drivers.

@carsonbot carsonbot added this to the 5.4 milestone Jan 12, 2022
@carsonbot carsonbot changed the title [DoctrineBridge][5.4] Fix automapping [DoctrineBridge] [5.4] Fix automapping Jan 12, 2022
@SimonVanacco
Copy link

This fixes the issue in my codebase !

@nicolas-grekas nicolas-grekas changed the title [DoctrineBridge] [5.4] Fix automapping [DoctrineBridge] Fix automapping Jan 26, 2022
@nicolas-grekas
Copy link
Member

Thank you @mbabker.

@nicolas-grekas nicolas-grekas merged commit 5cad3b6 into symfony:5.4 Jan 26, 2022
@mbabker mbabker deleted the fix-auto-mapping branch January 26, 2022 17:44
This was referenced Jan 28, 2022
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.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.