Skip to content

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

Closed
wants to merge 2 commits into from

Conversation

kocsismate
Copy link
Member

No description provided.

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");
Copy link
Member

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

Copy link
Member Author

@kocsismate kocsismate Aug 31, 2020

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);
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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();
Copy link
Member

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.

Copy link
Member Author

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. :)

@php-pulls php-pulls closed this in 7476d2c Sep 1, 2020
@kocsismate kocsismate deleted the tidy-warning branch September 1, 2020 12:20
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.

3 participants