Skip to content
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

Promote warnings to exceptions in ext/xmlreader #6021

Closed
wants to merge 3 commits into from

Conversation

@kocsismate
Copy link
Member

@kocsismate kocsismate commented Aug 19, 2020

No description provided.

php_error_docref(NULL, E_WARNING, "Unable to set schema. This must be set prior to reading or schema contains errors.");

RETURN_FALSE;
zend_throw_error(NULL, "Unable to set schema. This must be set prior to reading or schema contains errors.");

This comment has been minimized.

@nikic

nikic Aug 24, 2020
Member

"schema contains errors" doesn't sound like a promotable condition.

This comment has been minimized.

@nikic

nikic Aug 24, 2020
Member

I think this needs to be split into the error condition for !intern || !intern->ptr (can throw) and the one for retval != 0 (cannot throw).

This comment has been minimized.

@kocsismate

kocsismate Aug 24, 2020
Author Member

Thanks for the recommendation, I managed to separate them, and I added test coverage for both the warning and the exception.

@@ -781,8 +790,7 @@ PHP_METHOD(XMLReader, read)
}
}

php_error_docref(NULL, E_WARNING, "Load Data before trying to read");
RETURN_FALSE;
zend_throw_error(NULL, "Data must be loaded before reading");

This comment has been minimized.

@nikic

nikic Aug 24, 2020
Member

Style nit: Rewrite this as early return?

This comment has been minimized.

@kocsismate

kocsismate Aug 24, 2020
Author Member

Makes sense for me!

RETURN_BOOL(retval);
}
if (intern == NULL || intern->ptr == NULL) {
zend_throw_error(NULL, "Data must be loaded before reading");

This comment has been minimized.

@nikic

nikic Aug 25, 2020
Member

Missing a RETURN_THROWS().

@@ -506,15 +506,16 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t
intern->schema = schema;

RETURN_TRUE;
} else {
zend_throw_error(NULL, "Schema contains errors");

This comment has been minimized.

@nikic

nikic Aug 25, 2020
Member

This one should be a warning.

This comment has been minimized.

@kocsismate

kocsismate Aug 25, 2020
Author Member

:/ Both fixed now!

@nikic
nikic approved these changes Aug 25, 2020
@php-pulls php-pulls closed this in f068fbc Aug 25, 2020
@kocsismate kocsismate deleted the kocsismate:xmlreader-warning branch Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants