php{74,80}: libxml2 - fix tabs in patches

closes: #31963
closes: https://trac.macports.org/ticket/73663
This commit is contained in:
BjarneDMat
2026-04-12 15:07:00 +02:00
committed by Renee Otten
parent 97b3e95a11
commit e462f7c268
2 changed files with 109 additions and 36 deletions
+52 -16
View File
@@ -2,6 +2,11 @@ https://github.com/php/php-src/issues/12965 Build Failure With libxml2-2.12.
https://github.com/php/php-src/commit/0a39890 Fix libxml2 2.12 build due to API breaks
https://github.com/php/php-src/commit/8a95e61 Fix GH-12702: libxml2 2.12.0 issue building from src
/ext/xml/compat.c:569:35: warning: 'lastError' is deprecated [-Wdeprecated-declarations]
/opt/local/include/libxml2/libxml/parser.h:597:24: note: 'lastError' has been explicitly marked deprecated here
return !error && parser->parser->lastError.level <= XML_ERR_WARNING;
backporting from php81
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -25,6 +25,7 @@
@@ -25,18 +30,29 @@ https://github.com/php/php-src/commit/8a95e61 Fix GH-12702: libxml2 2.12.0 iss
--- a/ext/soap/php_sdl.c
+++ b/ext/soap/php_sdl.c
@@ -333,7 +333,7 @@ static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, int include)
sdl_restore_uri_credentials(ctx);
sdl_restore_uri_credentials(ctx);
if (!wsdl) {
- xmlErrorPtr xmlErrorPtr = xmlGetLastError();
+ const xmlError *xmlErrorPtr = xmlGetLastError();
if (!wsdl) {
- xmlErrorPtr xmlErrorPtr = xmlGetLastError();
+ const xmlError *xmlErrorPtr = xmlGetLastError();
if (xmlErrorPtr) {
soap_error2(E_ERROR, "Parsing WSDL: Couldn't load from '%s' : %s", struri, xmlErrorPtr->message);
if (xmlErrorPtr) {
soap_error2(E_ERROR, "Parsing WSDL: Couldn't load from '%s' : %s", struri, xmlErrorPtr->message);
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -476,7 +476,7 @@ php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc)
static xmlOutputBufferPtr
php_libxml_output_buffer_create_filename(const char *URI,
xmlCharEncodingHandlerPtr encoder,
- int compression ATTRIBUTE_UNUSED)
+ int compression __attribute__((__unused__)))
{
xmlOutputBufferPtr ret;
xmlURIPtr puri;
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -530,7 +530,11 @@ static int _php_libxml_free_error(xmlErrorPtr error)
return 1;
return 1;
}
-static void _php_list_set_error_structure(xmlErrorPtr error, const char *msg)
@@ -46,10 +62,10 @@ https://github.com/php/php-src/commit/8a95e61 Fix GH-12702: libxml2 2.12.0 iss
+static void _php_list_set_error_structure(xmlError *error, const char *msg)
+#endif
{
xmlError error_copy;
int ret;
xmlError error_copy;
int ret;
@@ -782,7 +786,11 @@ PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...)
va_end(args);
va_end(args);
}
+#if LIBXML_VERSION >= 21200
@@ -58,7 +74,7 @@ https://github.com/php/php-src/commit/8a95e61 Fix GH-12702: libxml2 2.12.0 iss
PHP_LIBXML_API void php_libxml_structured_error_handler(void *userData, xmlErrorPtr error)
+#endif
{
_php_list_set_error_structure(error, NULL);
_php_list_set_error_structure(error, NULL);
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -66,10 +82,30 @@ https://github.com/php/php-src/commit/8a95e61 Fix GH-12702: libxml2 2.12.0 iss
Retrieve last error from libxml */
static PHP_FUNCTION(libxml_get_last_error)
{
- xmlErrorPtr error;
- xmlErrorPtr error;
-
- error = xmlGetLastError();
+ const xmlError *error = xmlGetLastError();
- error = xmlGetLastError();
+ const xmlError *error = xmlGetLastError();
if (error) {
object_init_ex(return_value, libxmlerror_class_entry);
if (error) {
object_init_ex(return_value, libxmlerror_class_entry);
--- a/ext/xml/compat.c 2026-04-10 10:23:52
+++ b/ext/xml/compat.c 2026-04-10 10:19:04
@@ -563,10 +563,14 @@
PHP_XML_API int
XML_Parse(XML_Parser parser, const XML_Char *data, int data_len, int is_final)
{
- int error;
+ int error = xmlParseChunk(parser->parser, (char *) data, data_len, is_final);
- error = xmlParseChunk(parser->parser, (char *) data, data_len, is_final);
- return !error && parser->parser->lastError.level <= XML_ERR_WARNING;
+ if (!error) {
+ const xmlError *error_data = xmlCtxtGetLastError(parser->parser);
+ return !error_data || error_data->level <= XML_ERR_WARNING;
+ }
+
+ return 0;
}
PHP_XML_API int
+57 -20
View File
@@ -2,13 +2,18 @@ https://github.com/php/php-src/issues/12965 Build Failure With libxml2-2.12.
https://github.com/php/php-src/commit/0a39890 Fix libxml2 2.12 build due to API breaks
https://github.com/php/php-src/commit/8a95e61 Fix GH-12702: libxml2 2.12.0 issue building from src
/ext/xml/compat.c:569:35: warning: 'lastError' is deprecated [-Wdeprecated-declarations]
/opt/local/include/libxml2/libxml/parser.h:597:24: note: 'lastError' has been explicitly marked deprecated here
return !error && parser->parser->lastError.level <= XML_ERR_WARNING;
backporting from php81
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -23,6 +23,7 @@
#if defined(HAVE_LIBXML) && defined(HAVE_DOM)
#include "php_dom.h"
#include <libxml/SAX.h>
+#include <libxml/xmlxave.h>
+#include <libxml/xmlsave.h>
#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/relaxng.h>
#include <libxml/xmlschemas.h>
@@ -25,18 +30,29 @@ https://github.com/php/php-src/commit/8a95e61 Fix GH-12702: libxml2 2.12.0 iss
--- a/ext/soap/php_sdl.c
+++ b/ext/soap/php_sdl.c
@@ -331,7 +331,7 @@ static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, int include)
sdl_restore_uri_credentials(ctx);
sdl_restore_uri_credentials(ctx);
if (!wsdl) {
- xmlErrorPtr xmlErrorPtr = xmlGetLastError();
+ const xmlError *xmlErrorPtr = xmlGetLastError();
if (xmlErrorPtr) {
soap_error2(E_ERROR, "Parsing WSDL: Couldn't load from '%s' : %s", struri, xmlErrorPtr->message);
if (!wsdl) {
- xmlErrorPtr xmlErrorPtr = xmlGetLastError();
+ const xmlError *xmlErrorPtr = xmlGetLastError();
if (xmlErrorPtr) {
soap_error2(E_ERROR, "Parsing WSDL: Couldn't load from '%s' : %s", struri, xmlErrorPtr->message);
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -428,7 +428,7 @@ php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc)
static xmlOutputBufferPtr
php_libxml_output_buffer_create_filename(const char *URI,
xmlCharEncodingHandlerPtr encoder,
- int compression ATTRIBUTE_UNUSED)
+ int compression __attribute__((__unused__)))
{
xmlOutputBufferPtr ret;
xmlURIPtr puri;
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -481,7 +481,11 @@ static void _php_libxml_free_error(void *ptr)
xmlResetError((xmlErrorPtr) ptr);
xmlResetError((xmlErrorPtr) ptr);
}
-static void _php_list_set_error_structure(xmlErrorPtr error, const char *msg)
@@ -46,10 +62,10 @@ https://github.com/php/php-src/commit/8a95e61 Fix GH-12702: libxml2 2.12.0 iss
+static void _php_list_set_error_structure(xmlError *error, const char *msg)
+#endif
{
xmlError error_copy;
int ret;
xmlError error_copy;
int ret;
@@ -732,7 +736,11 @@ PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...)
va_end(args);
va_end(args);
}
+#if LIBXML_VERSION >= 21200
@@ -58,19 +74,40 @@ https://github.com/php/php-src/commit/8a95e61 Fix GH-12702: libxml2 2.12.0 iss
PHP_LIBXML_API void php_libxml_structured_error_handler(void *userData, xmlErrorPtr error)
+#endif
{
_php_list_set_error_structure(error, NULL);
_php_list_set_error_structure(error, NULL);
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -1044,10 +1044,8 @@
@@ -1043,11 +1043,9 @@
/* {{{ Retrieve last error from libxml */
PHP_FUNCTION(libxml_get_last_error)
{
- xmlErrorPtr error;
- xmlErrorPtr error;
-
ZEND_PARSE_PARAMETERS_NONE();
ZEND_PARSE_PARAMETERS_NONE();
- error = xmlGetLastError();
+ const xmlError *error = xmlGetLastError();
- error = xmlGetLastError();
+ const xmlError *error = xmlGetLastError();
if (error) {
object_init_ex(return_value, libxmlerror_class_entry);
if (error) {
object_init_ex(return_value, libxmlerror_class_entry);
--- a/ext/xml/compat.c 2026-04-10 10:23:52
+++ b/ext/xml/compat.c 2026-04-10 10:19:04
@@ -563,10 +563,14 @@
PHP_XML_API int
XML_Parse(XML_Parser parser, const XML_Char *data, int data_len, int is_final)
{
- int error;
+ int error = xmlParseChunk(parser->parser, (char *) data, data_len, is_final);
- error = xmlParseChunk(parser->parser, (char *) data, data_len, is_final);
- return !error && parser->parser->lastError.level <= XML_ERR_WARNING;
+ if (!error) {
+ const xmlError *error_data = xmlCtxtGetLastError(parser->parser);
+ return !error_data || error_data->level <= XML_ERR_WARNING;
+ }
+
+ return 0;
}
PHP_XML_API int