From d80be78efd94d8300678faa09badb25611683436 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 3 Jul 2024 17:07:10 +0200 Subject: [PATCH] Stop relying on the deprecated xmlLastError global --- ext/libxml/libxml.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index ad22b537ba6..b12113d14c5 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -843,14 +843,8 @@ PHP_LIBXML_API void php_libxml_pretend_ctx_error_ex(const char *file, int line, /* Propagate back into libxml */ if (LIBXML(error_list)) { xmlErrorPtr last = zend_llist_get_last(LIBXML(error_list)); - if (last) { - if (!last->file) { - last->file = strdup(file); - } - /* Until there is a replacement */ - ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") - xmlCopyError(last, &xmlLastError); - ZEND_DIAGNOSTIC_IGNORED_END + if (last && !last->file) { + last->file = strdup(file); } } } @@ -1126,7 +1120,13 @@ PHP_FUNCTION(libxml_get_last_error) { ZEND_PARSE_PARAMETERS_NONE(); - const xmlError *error = xmlGetLastError(); + const xmlError *error; + + if (LIBXML(error_list)) { + error = zend_llist_get_last(LIBXML(error_list)); + } else { + error = xmlGetLastError(); + } if (error) { php_libxml_create_error_object(return_value, error);