Skip to content

[RFC] FILTER_THROW_ON_FAILURE #18896

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DanielEScherzer
Copy link
Member

@DanielEScherzer DanielEScherzer commented Jun 21, 2025

@DanielEScherzer DanielEScherzer linked an issue Jun 21, 2025 that may be closed by this pull request
@DanielEScherzer DanielEScherzer changed the title [RFC} FILTER_THROW_ON_FAILURE [RFC] FILTER_THROW_ON_FAILURE Jun 21, 2025
@DanielEScherzer DanielEScherzer marked this pull request as draft June 22, 2025 00:21
@DanielEScherzer DanielEScherzer force-pushed the filter-throw-on-failure branch from 8c5abca to 86969e5 Compare June 22, 2025 05:52
@divinity76
Copy link
Contributor

LGTM fwiw. (I don't have access use the actual github review form on php-src, but it lgtm.)

zend_throw_exception_ex(
php_filter_failed_exception_ce,
0,
"filter validation failed: filter %s not satisfied by %s",
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to use ' around the %s's? In the error message, you can now end up with a phrase like:

filter validation failed: filter %s not satisfied by elephpants

Which reads as a joke... as it's unclear whether elephpants are the variable contents that the filter is operating on.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done for this one, since the second %s is a string version of the value

zend_throw_exception_ex(
php_filter_failed_exception_ce,
0,
"filter validation failed: not an array (got %s)",
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Member Author

Choose a reason for hiding this comment

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

Here %s is not just the string value, it can also be "true"/"false"/"null" for true/false/null, or a class name; I think quotes here would be more confusing, and the name is clearly everything after the "got"

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe

Z_TYPE_P(value) == IS_STRING ?
"filter validation failed: not an array (got '%s')"
: "filter validation failed: not an array (got %s)"

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.

FILTER_THROW_ON_FAILURE flag?
3 participants