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

[Validator] return empty metadata collection if none do exist #11614

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

Closed
wants to merge 1 commit into from

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Aug 8, 2014

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #11604
License MIT
Doc PR

@xabbuh xabbuh changed the title [Validator] return empty metadata collection if no exist [Validator] return empty metadata collection if any do exist Aug 8, 2014
@xabbuh
Copy link
Member Author

xabbuh commented Aug 8, 2014

The ClassMetadata class already existed in older Symfony versions. Should I provide a separate fix for these versions?

@stof
Copy link
Member

stof commented Aug 8, 2014

The same check is needed in getMemberMetadata. And it should indeed be fixed in the older affected version (among maintained ones, which means starting with 2.3)

@xabbuh
Copy link
Member Author

xabbuh commented Aug 8, 2014

@stof Thanks, you're right. Updated it.

@xabbuh xabbuh changed the title [Validator] return empty metadata collection if any do exist [Validator] return empty metadata collection if none do exist Aug 8, 2014
The PropertyMetadataContainerInterface defines that the method
getPropertyMetadata() has to return an empty collection if no
metadata have been configured for the given property. Though, its
implementation in the ClassMetadata class didn't check for
existence of such metadata. This behavior led to unexpected PHP
notices when validating a property or a property value of a property
without any configured constraints (only affects the new 2.5 API).
Additionally, the getMemberMetadatas() didn't check for existing
array keys as well which has also been fixed.
@stof
Copy link
Member

stof commented Aug 18, 2014

👍

ping @symfony/deciders

@@ -371,6 +371,10 @@ public function hasMemberMetadatas($property)
*/
public function getMemberMetadatas($property)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this method when it has the same implementation as getPropertyMetadata?

Copy link
Member Author

Choose a reason for hiding this comment

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

getPropertyMetadata() was introduced in efe42cb. I guess getMemberMetadatas() was kept for BC.

Copy link
Member

Choose a reason for hiding this comment

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

yep, it is the BC layer

Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't it be @deprecated then?!

Copy link
Member

Choose a reason for hiding this comment

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

it is deprecated at the interface level. This class implements both the new interface and the deprecated one

Copy link
Member

Choose a reason for hiding this comment

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

indeed, looks like a left-over of an even older implementation

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that it should be deprecated. Though not in this pull request I guess. Should I add it in #11615 or open another PR for it?

Copy link
Member

Choose a reason for hiding this comment

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

we should only deprecate things in master, not in 2.3

Copy link
Contributor

Choose a reason for hiding this comment

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

Ill make a PR

Copy link
Contributor

Choose a reason for hiding this comment

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

see #11703

webmozart added a commit that referenced this pull request Aug 19, 2014
…exist (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[Validator] return empty metadata collection if none do exist

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        | [The reference to the documentation PR if any]

Backport of #11614 for Symfony 2.3 and 2.4.

Commits
-------

f5bc18d return empty metadata collection if none do exist
@webmozart
Copy link
Contributor

Merged into 2.3.

@webmozart webmozart closed this Aug 19, 2014
@stof
Copy link
Member

stof commented Aug 19, 2014

@webmozart this PR was adding an extra test. Is it worth adding it ?

@xabbuh
Copy link
Member Author

xabbuh commented Aug 19, 2014

@webmozart In addition to #11615, this also contains test for the AbstractValidator which was introduced in 2.5.

@webmozart
Copy link
Contributor

@xabbuh Indeed. Would you mind opening a new PR with these tests?

@stof
Copy link
Member

stof commented Aug 19, 2014

@xabbuh the question is whether this test is worth it now that we have the test for the ClassMetadata itself

@webmozart
Copy link
Contributor

@stof I think it is.

@xabbuh
Copy link
Member Author

xabbuh commented Aug 19, 2014

@stof The question is if we want to keep it to avoid regressions. There may be other reasons in the future for the AbstractValidator to fail when there is no class metadata.

@xabbuh
Copy link
Member Author

xabbuh commented Aug 19, 2014

@webmozart see #11707

fabpot added a commit that referenced this pull request Aug 31, 2014
…straint is defined (xabbuh)

This PR was merged into the 2.5 branch.

Discussion
----------

[Validator] Test that validateProperty() works if no constraint is defined

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes (2.3 has to be merged into 2.5 first)
| Fixed tickets | #11604, #11614
| License       | MIT
| Doc PR        |

Adds a test case for #11604 to avoid regressions. The actual issue has been fixed in Symfony 2.3 with the merge of #11615.

Commits
-------

a47a884 add test for #11604
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.

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