-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
PropertyInfoLoader should not try to add validation to non-existent property #31936
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
PropertyInfoLoader should not try to add validation to non-existent property #31936
Conversation
4af9fa1
to
89f72a1
Compare
@@ -60,6 +60,10 @@ public function loadClassMetadata(ClassMetadata $metadata) | |||
continue; | |||
} | |||
|
|||
if (false === property_exists($className, $property)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
property_exists() is what is used in PropertyMetadata, which triggered the exception. This matches that.
@@ -46,6 +46,7 @@ public function testLoadClassMetadata() | |||
'alreadyMappedNotBlank', | |||
'alreadyPartiallyMappedCollection', | |||
'readOnly', | |||
'nonExistentField', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No asserts were added, but, without the fix, these changes are enough to trigger an exception to be thrown while running this test.
…istent properties
89f72a1
to
b702598
Compare
Thank you @weaverryan. |
…-existent property (weaverryan) This PR was merged into the 4.3 branch. Discussion ---------- PropertyInfoLoader should not try to add validation to non-existent property | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #31796 (see #31796 (comment)) | License | MIT | Doc PR | not needed With auto-validation, if a class has a setter (e.g. `setFoo()`) but there is no `foo` property, it still tries to add validation to that property, resulting in a: > Property "foo" does not exist in class "App\Entity\Bar This fixes that. I believe it's "just this simple", but I don't have any experience with the code in this area yet. Cheers! Commits ------- b702598 Fixing bug where PropertyInfoLoader tried to add validation to non-existent properties
Looks good to me! Thank you Ryan. |
With auto-validation, if a class has a setter (e.g.
setFoo()
) but there is nofoo
property, it still tries to add validation to that property, resulting in a:This fixes that. I believe it's "just this simple", but I don't have any experience with the code in this area yet.
Cheers!