Skip to content

Commit 40f4091

Browse files
committed
Fix arginfo/zpp violations when LIBXML_SCHEMAS_ENABLED is not available
To do this, we move the macro check and therefore we also have to move some variable declarations to avoid compiler warnings. Closes phpGH-20130.
1 parent ab9d121 commit 40f4091

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ PHP NEWS
1818
- Random:
1919
. Fix Randomizer::__serialize() w.r.t. INDIRECTs. (nielsdos)
2020

21+
- XMLReader:
22+
. Fix arginfo/zpp violations when LIBXML_SCHEMAS_ENABLED is not available.
23+
(nielsdos)
24+
2125
23 Oct 2025, PHP 8.3.27
2226

2327
- Core:

ext/xmlreader/php_xmlreader.c

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,7 @@ static void php_xmlreader_no_arg_string(INTERNAL_FUNCTION_PARAMETERS, xmlreader_
468468

469469
/* {{{ php_xmlreader_set_relaxng_schema */
470470
static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int type) {
471-
#ifdef LIBXML_SCHEMAS_ENABLED
472-
zval *id;
473471
size_t source_len = 0;
474-
int retval = -1;
475-
xmlreader_object *intern;
476-
xmlRelaxNGPtr schema = NULL;
477472
char *source;
478473

479474
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p!", &source, &source_len) == FAILURE) {
@@ -484,11 +479,13 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t
484479
zend_argument_value_error(1, "cannot be empty");
485480
RETURN_THROWS();
486481
}
487-
488-
id = ZEND_THIS;
489-
490-
intern = Z_XMLREADER_P(id);
482+
483+
#ifdef LIBXML_SCHEMAS_ENABLED
484+
xmlreader_object *intern = Z_XMLREADER_P(ZEND_THIS);
491485
if (intern->ptr) {
486+
int retval = -1;
487+
xmlRelaxNGPtr schema = NULL;
488+
492489
if (source) {
493490
schema = _xmlreader_get_relaxNG(source, source_len, type, NULL, NULL);
494491
if (schema) {
@@ -926,11 +923,7 @@ PHP_METHOD(XMLReader, readString)
926923
/* {{{ Use W3C XSD schema to validate the document as it is processed. Activation is only possible before the first Read(). */
927924
PHP_METHOD(XMLReader, setSchema)
928925
{
929-
#ifdef LIBXML_SCHEMAS_ENABLED
930-
zval *id;
931926
size_t source_len = 0;
932-
int retval = -1;
933-
xmlreader_object *intern;
934927
char *source;
935928

936929
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p!", &source, &source_len) == FAILURE) {
@@ -941,13 +934,12 @@ PHP_METHOD(XMLReader, setSchema)
941934
zend_argument_value_error(1, "cannot be empty");
942935
RETURN_THROWS();
943936
}
944-
945-
id = ZEND_THIS;
946-
947-
intern = Z_XMLREADER_P(id);
937+
938+
#ifdef LIBXML_SCHEMAS_ENABLED
939+
xmlreader_object *intern = Z_XMLREADER_P(ZEND_THIS);
948940
if (intern && intern->ptr) {
949941
PHP_LIBXML_SANITIZE_GLOBALS(schema);
950-
retval = xmlTextReaderSchemaValidate(intern->ptr, source);
942+
int retval = xmlTextReaderSchemaValidate(intern->ptr, source);
951943
PHP_LIBXML_RESTORE_GLOBALS(schema);
952944

953945
if (retval == 0) {

0 commit comments

Comments
 (0)