Skip to content

[Validator] Reset constraint options #20122

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
Oct 2, 2016
Merged

[Validator] Reset constraint options #20122

merged 1 commit into from
Oct 2, 2016

Conversation

ro0NL
Copy link
Contributor

@ro0NL ro0NL commented Oct 1, 2016

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #20106
License MIT
Doc PR reference to the documentation PR, if any

I think it's good to reset the internal pointer of the options array if we depend on key($options). I've added tests to clarify we intentionally check for the first key.

The current behavior actually differs for hhvm/php7 - https://3v4l.org/e6r6E

Copy link
Contributor

@lemoinem lemoinem left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. Looks good to me.

@fabpot
Copy link
Member

fabpot commented Oct 2, 2016

Have you check if this is the only place where we need that?

@lemoinem
Copy link
Contributor

lemoinem commented Oct 2, 2016

@fabpot I grep'd through the Validator Component for key() or current().

The only other time they are used is in the YamlFileLoader. And I don't think it's possible for this array to have a misplaced internal pointer (single element array, generated by the Yaml Parser).

@fabpot
Copy link
Member

fabpot commented Oct 2, 2016

I was thinking about the other components and bundles as well.

@lemoinem
Copy link
Contributor

lemoinem commented Oct 2, 2016

I'll take a look.

@lemoinem
Copy link
Contributor

lemoinem commented Oct 2, 2016

@fabpot I double checked the rest of symfony's code. As far as I can tell, all other uses of current() and key() are safe (most are on newly built arrays, the others are on arrays being iterated on).

@ro0NL
Copy link
Contributor Author

ro0NL commented Oct 2, 2016

We should be careful though, it needs to be looked at on a per case basis.

I've double checked all subclasses, and overridden constructors are good to go.

@fabpot
Copy link
Member

fabpot commented Oct 2, 2016

Thank you @ro0NL.

@fabpot fabpot merged commit 4c6ddd4 into symfony:2.7 Oct 2, 2016
fabpot added a commit that referenced this pull request Oct 2, 2016
This PR was merged into the 2.7 branch.

Discussion
----------

[Validator] Reset constraint options

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20106
| License       | MIT
| Doc PR        | reference to the documentation PR, if any

I think it's good to reset the internal pointer of the options array if we depend on `key($options)`. I've added tests to clarify we intentionally check for the first key.

The current behavior actually differs for hhvm/php7 - https://3v4l.org/e6r6E

Commits
-------

4c6ddd4 reset constraint options
@ro0NL ro0NL deleted the validator/reset-options branch October 2, 2016 15:59
This was referenced Oct 3, 2016
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.

4 participants