Skip to content
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

Do not validate null values in UserPassword\UniqueEntity validators #23319

Closed
szymach opened this issue Jun 28, 2017 · 3 comments
Closed

Do not validate null values in UserPassword\UniqueEntity validators #23319

szymach opened this issue Jun 28, 2017 · 3 comments

Comments

@szymach
Copy link

szymach commented Jun 28, 2017

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? yes
Symfony version Checked on 3.2, I assume it is for 3.* in general

Hello,
I have ran into an issue when using the Symfony\Component\Security\Core\Validator\Constraints\UserPassword validator and PHP 7.1 - if the field value is empty (a null), the validator breaks on this line with a warning hash_equals(): Expected user_string to be a string, null given.

Usually validators simply check the value for a null and return if found, but here it just passes it on further and allows it to break. Same goes for Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator and it requires me to overwrite these classes and manually add a check for null. I can make a PR fixing this, assuming everyone is fine with this change.

@xabbuh
Copy link
Member

xabbuh commented Jun 28, 2017

This looks indeed like an issue to me.

@Hanmac
Copy link
Contributor

Hanmac commented Jun 29, 2017

i think the validators should ignore null, and because that can be validated later with the NotNull one.

@xabbuh
Copy link
Member

xabbuh commented Jun 30, 2017

This should be fixed when #23341 gets merged.

fabpot added a commit that referenced this issue Jul 3, 2017
…y values (xabbuh)

This PR was merged into the 2.7 branch.

Discussion
----------

[DoctrineBridge][Security][Validator] do not validate empty values

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23319
| License       | MIT
| Doc PR        |

Nearly all validators operating on scalar values (except for some special constraints) do ignore empty values. If you want to forbid them, you have to use the `NotBlank` constraint instead.

Commits
-------

fd7ad23 do not validate empty values
@fabpot fabpot closed this as completed Jul 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants