Fix ORM 3 inverse-side mappings without inversedBy#1641
Open
alexmart wants to merge 1 commit intoergebnis:mainfrom
Open
Fix ORM 3 inverse-side mappings without inversedBy#1641alexmart wants to merge 1 commit intoergebnis:mainfrom
alexmart wants to merge 1 commit intoergebnis:mainfrom
Conversation
Doctrine ORM 3 returns mapping objects for inverse one-to-one associations that do not expose an inversedBy property. Accessing it triggers a runtime error. Guard the property access and return null when inversedBy is unavailable so association updates are skipped safely. Add a regression test with a single-valued inverse-side one-to-one association to prove fixture creation no longer fails.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1641 +/- ##
=========================================
Coverage 99.23% 99.24%
- Complexity 107 108 +1
=========================================
Files 28 28
Lines 393 395 +2
=========================================
+ Hits 390 392 +2
Misses 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When using Doctrine ORM 3,
ClassMetadata::getAssociationMapping()can return mapping objects for inverse-side one-to-one associations (for exampleOneToOneInverseSideMapping) that do not expose aninversedByproperty.FixtureFactory::resolveInversedBy()currently accesses$association->inversedByunconditionally for object mappings, which triggers a runtime error in this case.What this changes
nullwhen an association mapping object has noinversedByproperty.Fingerprint::$device) to verify fixture creation does not fail.Why this is safe
updateCollectionSideOfAssociation()already treats a non-string result fromresolveInversedBy()as a no-op, so returningnullcleanly skips back-reference updates where they are not applicable.Verification
vendor/bin/phpunit --configuration=test/phpunit.xml --testsuite=unitvendor/bin/phpunit --configuration=test/phpunit.xml --testsuite=integrationvendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --dry-run --diff