Stop relying on the deprecated xmlLastError global

This commit is contained in:
Niels Dossche 2024-07-03 17:07:10 +02:00
parent ef80266d99
commit d80be78efd

View file

@ -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);