8000 [Form][DateTimeToArrayTransformer] Check for hour, minute & second validity by egeloen · Pull Request #9441 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form][DateTimeToArrayTransformer] Check for hour, minute & second validity #9441

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

egeloen
Copy link
@egeloen egeloen commented Nov 4, 2013
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #9440
License MIT
Doc PR -

This PR checks if hour, minute & second values are valid in the datetime to array transformer (values must be integer if they exist).

@egeloen
Copy link
Author
egeloen commented Nov 4, 2013

I can't find a way to fix failing tests after applying this patch. Can you explain the use case of the failing tests which result of this PR?

@@ -160,6 +160,18 @@ public function reverseTransform($value)
throw new TransformationFailedException('This is an invalid date');
}

if (isset($value['hour']) && !ctype_digit($value['hour']) && !is_int($value['hour'])) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can simplify this and the following lines to

if (isset($value['hour']) && !ctype_digit((string) $value['hour'])) {

Copy link
Author

Choose a reason for hiding this comment

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

I have based this condition according to the other related to the date field (just above this change). Should I change them too?

Copy link
Author

Choose a reason for hiding this comment

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

For the record, I have changed them.

@webmozart
Copy link
Contributor

The failing tests in AbstractLayoutTest were intended to test the output escaping of the values. Now that you added strict validation of the values, you can change the test to pass numbers instead of strings.

@egeloen
Copy link
Author
egeloen commented Nov 9, 2013

@bschussek Okay thx for your feedback!

@egeloen
Copy link
Author
egeloen commented Nov 12, 2013

IMO, the PR is ready!

@egeloen
Copy link
Author
egeloen commented Nov 19, 2013

@bschussek @fabpot Something else needs to be done?

@egeloen
Copy link
Author
egeloen commented Dec 1, 2013

ping someone 👶 :)

fabpot added a commit that referenced this pull request Dec 27, 2013
… second validity (egeloen)

This PR was submitted for the 2.3-dev branch but it was merged into the 2.3 branch instead (closes #9441).

Discussion
----------

[Form][DateTimeToArrayTransformer] Check for hour, minute & second validity

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

This PR checks if hour, minute & second values are valid in the datetime to array transformer (values must be integer if they exist).

Commits
-------

1543653 [Form][DateTimeToArrayTransformer] Check for hour, minute & second validity
@egeloen egeloen deleted the f-datetime-array-transformer branch December 28, 2013 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0