Skip to content

Commit 4401b03

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: libxml: Fix some deprecations regarding input buffer/parser handling
2 parents b4eea9c + 6054a90 commit 4401b03

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ PHP NEWS
2626
. Fixed bug GH-20483 (ASAN stack overflow with fiber.stack_size INI
2727
small value). (David Carlier)
2828

29+
- LibXML:
30+
. Fix some deprecations on newer libxml versions regarding input
31+
buffer/parser handling. (ndossche)
32+
2933
- Opcache:
3034
. Fixed bug GH-20329 (opcache.file_cache broken with full interned string
3135
buffer). (Arnaud)

ext/libxml/libxml.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,10 @@ php_libxml_output_buffer_create_filename(const char *URI,
611611
}
612612

613613
/* Allocate the Output buffer front-end. */
614-
ret = xmlAllocOutputBuffer(encoder);
615-
if (ret != NULL) {
616-
ret->context = context;
617-
ret->writecallback = php_libxml_streams_IO_write;
618-
ret->closecallback = php_libxml_streams_IO_close;
614+
ret = xmlOutputBufferCreateIO(php_libxml_streams_IO_write, php_libxml_streams_IO_close, context, encoder);
615+
if (ret == NULL) {
616+
php_libxml_streams_IO_close(context);
617+
goto err;
619618
}
620619

621620
return(ret);
@@ -802,6 +801,7 @@ static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL,
802801
zend_string_release(callable_name);
803802
zval_ptr_dtor(&callable);
804803
} else {
804+
#if LIBXML_VERSION < 21400
805805
/* TODO: allow storing the encoding in the stream context? */
806806
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
807807
xmlParserInputBufferPtr pib = xmlAllocParserInputBuffer(enc);
@@ -820,6 +820,12 @@ static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL,
820820
xmlFreeParserInputBuffer(pib);
821821
}
822822
}
823+
#else
824+
/* make stream not being closed when the zval is freed */
825+
GC_ADDREF(stream->res);
826+
ret = xmlNewInputFromIO(NULL, php_libxml_streams_IO_read, php_libxml_streams_IO_close, stream, 0);
827+
/* Note: if ret == NULL, the close operation will be executed, so don't DELREF stream->res upon failure! */
828+
#endif
823829
}
824830
} else if (Z_TYPE(retval) != IS_NULL) {
825831
/* retval not string nor resource nor null; convert to string */

0 commit comments

Comments
 (0)