Skip to content

[Validator] [Choice] Fix callback option if not array returned #58615

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

Conversation

symfonyaml
Copy link
Contributor

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #58610
License MIT

Issue

When using the Choice validator callback option, and the callback method provided does not return an array or iterable, it causes a PHP error.
See all details and how to reproduce it in the issue #58610

Solution

In this PR

  • Add some checks if the callback method provided returns an array or iterable
  • Add tests for exception and iterable

NOTE : This PR replaces the old one (I messed up with the branch rebase)

@carsonbot carsonbot added this to the 5.4 milestone Oct 21, 2024
@carsonbot carsonbot changed the title [Validator][Choice] Fix callback option if not array or iterable retu… [Validator] [Choice] Fix callback option if not array or iterable retu… Oct 21, 2024
@symfonyaml symfonyaml changed the title [Validator] [Choice] Fix callback option if not array or iterable retu… [Validator] [Choice] Fix callback option if not array Oct 22, 2024
@symfonyaml symfonyaml changed the title [Validator] [Choice] Fix callback option if not array [Validator] [Choice] Fix callback option if not array returned Oct 22, 2024
@nicolas-grekas nicolas-grekas force-pushed the validator-choice-callback-traversable branch from 20e6cc9 to 02d2769 Compare October 22, 2024 19:04
@nicolas-grekas
Copy link
Member

Thank you @symfonyaml.

@nicolas-grekas nicolas-grekas merged commit 8096a42 into symfony:5.4 Oct 22, 2024
7 of 8 checks passed
This was referenced Oct 27, 2024
@symfonyaml symfonyaml deleted the validator-choice-callback-traversable branch November 29, 2024 13:51
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