Promote warnings to exceptions in ext/xmlreader #6021
Closed
Conversation
ext/xmlreader/php_xmlreader.c
Outdated
| 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."); |
nikic
Aug 24, 2020
Member
"schema contains errors" doesn't sound like a promotable condition.
"schema contains errors" doesn't sound like a promotable condition.
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).
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).
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.
Thanks for the recommendation, I managed to separate them, and I added test coverage for both the warning and the exception.
ext/xmlreader/php_xmlreader.c
Outdated
| @@ -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"); | |||
nikic
Aug 24, 2020
Member
Style nit: Rewrite this as early return?
Style nit: Rewrite this as early return?
kocsismate
Aug 24, 2020
Author
Member
Makes sense for me!
Makes sense for me!
| RETURN_BOOL(retval); | ||
| } | ||
| if (intern == NULL || intern->ptr == NULL) { | ||
| zend_throw_error(NULL, "Data must be loaded before reading"); |
nikic
Aug 25, 2020
Member
Missing a RETURN_THROWS().
Missing a RETURN_THROWS().
ext/xmlreader/php_xmlreader.c
Outdated
| @@ -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"); | |||
nikic
Aug 25, 2020
Member
This one should be a warning.
This one should be a warning.
kocsismate
Aug 25, 2020
Author
Member
:/ Both fixed now!
:/ Both fixed now!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
No description provided.