-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Promote warnings to exceptions in ext/tidy #6051
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
Conversation
74188b0
to
3292fd8
Compare
RETURN_FALSE; | ||
} | ||
|
||
if (ZEND_SIZE_T_UINT_OVFL(ZSTR_LEN(contents))) { | ||
php_error_docref(NULL, E_WARNING, "Input string is too long"); | ||
RETURN_FALSE; | ||
zend_value_error("Input string is too long"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this use zend_arguent_value_error()
as you are in a PHP_FUNCTION
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zend_arguent_value_error()
doesn't really support the wording which is needed here. It should say something like: Argument ... is a file whose contents is too long
. I can't make it make sense. :)
@@ -289,12 +289,12 @@ static int _php_tidy_set_tidy_opt(TidyDoc doc, char *optname, zval *value) | |||
zend_long lval; | |||
|
|||
if (!opt) { | |||
php_error_docref(NULL, E_NOTICE, "Unknown Tidy Configuration Option '%s'", optname); | |||
php_error_docref(NULL, E_WARNING, "Unknown Tidy configuration option \"%s\"", optname); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this can be bumped to a ValueError in 8.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that very similar errors below are now ValueError, I think we should indeed do that for the sake of consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only notable difference from the rest is that when this warning is emitted, processing continues, and the option is ignored (it comes from an array). That's the main reason I didn't want to take 2 steps ahead and make it an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, yeah, that makes sense.
php_error_docref(NULL, E_WARNING, "Unknown Tidy Configuration Option '%s'", optname); | ||
RETURN_FALSE; | ||
zend_argument_value_error(getThis() ? 1 : 2, "is an invalid configuration option"); | ||
RETURN_THROWS(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like one of the cases where showing the passed string in the error message might make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I don't have any hard feelings against this, let's do it. But in the future (for PHP 8.1+) we should consolidate when to show these values, because this message will be an outlier from the rest now. :)
3292fd8
to
278578a
Compare
No description provided.