Skip to content

Promote warnings to exceptions in ext/xmlreader - #6021

Closed
kocsismate wants to merge 3 commits into
php:masterfrom
kocsismate:xmlreader-warning
Closed

Promote warnings to exceptions in ext/xmlreader#6021
kocsismate wants to merge 3 commits into
php:masterfrom
kocsismate:xmlreader-warning

Conversation

@kocsismate

Copy link
Copy Markdown
Member

No description provided.

Comment threadext/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.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

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

Comment threadext/xmlreader/php_xmlreader.c Outdated

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Style nit: Rewrite this as early return?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Makes sense for me!

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Missing a RETURN_THROWS().

Comment threadext/xmlreader/php_xmlreader.c Outdated

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This one should be a warning.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

:/ Both fixed now!

@kocsismate
kocsismate deleted the xmlreader-warning branch August 25, 2020 09:56
Sign up for freeto 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.

2 participants

@kocsismate@nikic