Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions ext/xmlreader/php_xmlreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,7 @@ static void php_xmlreader_no_arg_string(INTERNAL_FUNCTION_PARAMETERS, xmlreader_

/* {{{ php_xmlreader_set_relaxng_schema */
static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int type) {
#ifdef LIBXML_SCHEMAS_ENABLED
zval *id;
size_t source_len = 0;
int retval = -1;
xmlreader_object *intern;
xmlRelaxNGPtr schema = NULL;
char *source;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "p!", &source, &source_len) == FAILURE) {
Expand All @@ -484,11 +479,13 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t
zend_argument_value_error(1, "cannot be empty");
RETURN_THROWS();
}

id = ZEND_THIS;

intern = Z_XMLREADER_P(id);

#ifdef LIBXML_SCHEMAS_ENABLED
xmlreader_object *intern = Z_XMLREADER_P(ZEND_THIS);
if (intern->ptr) {
int retval = -1;
xmlRelaxNGPtr schema = NULL;

if (source) {
schema = _xmlreader_get_relaxNG(source, source_len, type, NULL, NULL);
if (schema) {
Expand Down Expand Up @@ -926,11 +923,7 @@ PHP_METHOD(XMLReader, readString)
/* {{{ Use W3C XSD schema to validate the document as it is processed. Activation is only possible before the first Read(). */
PHP_METHOD(XMLReader, setSchema)
{
#ifdef LIBXML_SCHEMAS_ENABLED
Comment on lines 924 to -929
Copy link
Member

Choose a reason for hiding this comment

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

That the method need to exist? As normally we only expose functions/methods for functionality that is available. Obviously this is not a fix that is possible for 8.3.

Copy link
Member Author

Choose a reason for hiding this comment

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

Normally we should make the method conditionally available indeed. As atm it is hard to polyfill this.
There are more of these kind of cases unfortunately. We should try to make an effort to find them on master and do the right thing there. That's not very high priority though.

zval *id;
size_t source_len = 0;
int retval = -1;
xmlreader_object *intern;
char *source;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "p!", &source, &source_len) == FAILURE) {
Expand All @@ -941,13 +934,12 @@ PHP_METHOD(XMLReader, setSchema)
zend_argument_value_error(1, "cannot be empty");
RETURN_THROWS();
}

id = ZEND_THIS;

intern = Z_XMLREADER_P(id);

#ifdef LIBXML_SCHEMAS_ENABLED
xmlreader_object *intern = Z_XMLREADER_P(ZEND_THIS);
if (intern && intern->ptr) {
PHP_LIBXML_SANITIZE_GLOBALS(schema);
retval = xmlTextReaderSchemaValidate(intern->ptr, source);
int retval = xmlTextReaderSchemaValidate(intern->ptr, source);
PHP_LIBXML_RESTORE_GLOBALS(schema);

if (retval == 0) {
Expand Down
Loading