Skip to content

[Serializer] avoid calling undefined built-in is_*() functions #57320

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
Jun 6, 2024

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Jun 5, 2024

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

Comment on lines 569 to 583
$dataMatchesExpectedType = match ($builtinType) {
LegacyType::BUILTIN_TYPE_ARRAY => \is_array($data),
LegacyType::BUILTIN_TYPE_BOOL => \is_bool($data),
LegacyType::BUILTIN_TYPE_CALLABLE => \is_callable($data),
LegacyType::BUILTIN_TYPE_FALSE => false === $data,
LegacyType::BUILTIN_TYPE_FLOAT => \is_float($data),
LegacyType::BUILTIN_TYPE_INT => \is_int($data),
LegacyType::BUILTIN_TYPE_ITERABLE => is_iterable($data),
LegacyType::BUILTIN_TYPE_NULL => null === $data,
LegacyType::BUILTIN_TYPE_OBJECT => \is_object($data),
LegacyType::BUILTIN_TYPE_RESOURCE => $data,
LegacyType::BUILTIN_TYPE_STRING => \is_string($data),
LegacyType::BUILTIN_TYPE_TRUE => true === $data,
default => false,
};
Copy link
Member

Choose a reason for hiding this comment

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

Would worth a private method maybe? As you're using the same logic twice?

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact, the legacy type doesn't support mixed here. So I have reverted these changes.

Copy link
Member

Choose a reason for hiding this comment

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

@xabbuh the bug is not only for mixed. See #57334 reporting the issue for false (and probably also true). And the legacy type does support false

Copy link
Member Author

Choose a reason for hiding this comment

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

@stof You are right, but we need to fix this on the 5.4 branch (see #57341).

@xabbuh xabbuh merged commit 322e7e4 into symfony:7.1 Jun 6, 2024
8 of 10 checks passed
@xabbuh xabbuh deleted the issue-57314 branch June 6, 2024 12:37
@HectorOrdonez
Copy link

Hello! When are we planning to release this? It's a breaking change for us.

@xabbuh
Copy link
Member Author

xabbuh commented Jun 12, 2024

Patch releases are published once a month.

xabbuh added a commit that referenced this pull request Jun 16, 2024
…ypes (xabbuh)

This PR was merged into the 5.4 branch.

Discussion
----------

[Serializer] properly handle invalid data for false/true types

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #57320 (comment)
| License       | MIT

Commits
-------

d35d4a3 properly handle invalid data for false/true types
symfony-splitter pushed a commit to symfony/serializer that referenced this pull request Jun 16, 2024
…ypes (xabbuh)

This PR was merged into the 5.4 branch.

Discussion
----------

[Serializer] properly handle invalid data for false/true types

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix symfony/symfony#57320 (comment)
| License       | MIT

Commits
-------

d35d4a337b properly handle invalid data for false/true types
@fabpot fabpot mentioned this pull request Jun 28, 2024
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.

6 participants