Skip to content

Commit 569e268

Browse files
mszabo-wikiafacebook-github-bot
authored andcommitted
Fix libxml and soap extension with libxml >= 2.12.0 (#9572)
Summary: libxml 2.12.0 changes the API to return `const xmlError*` in several places.[1] As a fix, use auto variables for storing the output of xmlGetLastError() and make the signature of our error handler function dependent on the libxml version. Split from #9564. [1] https://gitlab.gnome.org/GNOME/libxml2/-/blob/86401cc3d293d6ea3c4552885e3cadcd952021d1/NEWS#L392 Pull Request resolved: #9572 Reviewed By: Wilfred Differential Revision: D67922353 fbshipit-source-id: 36eded2295fdd60d15ff559d4d79eb5732c5598f
1 parent b38b525 commit 569e268

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

hphp/runtime/ext/libxml/ext_libxml.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <libxml/uri.h>
3737
#include <libxml/xmlerror.h>
3838
#include <libxml/xmlsave.h>
39+
#include <libxml/xmlversion.h>
3940
#ifdef LIBXML_SCHEMAS_ENABLED
4041
#include <libxml/relaxng.h>
4142
#include <libxml/xmlschemas.h>
@@ -624,7 +625,11 @@ String libxml_get_valid_file_path(const String& source) {
624625
return file_dest;
625626
}
626627

628+
#if LIBXML_VERSION >= 21200
629+
static void libxml_error_handler(void* /*userData*/, const xmlError* error) {
630+
#else
627631
static void libxml_error_handler(void* /*userData*/, xmlErrorPtr error) {
632+
#endif
628633
if (rl_libxml_request_data->m_suppress_error) {
629634
return;
630635
}
@@ -642,7 +647,7 @@ static void libxml_error_handler(void* /*userData*/, xmlErrorPtr error) {
642647
}
643648
}
644649

645-
static Object create_libxmlerror(xmlError &error) {
650+
static Object create_libxmlerror(const xmlError &error) {
646651
Object ret{ LibXMLError::classof() };
647652
// Setting only public properties
648653
ret->setProp(nullctx, s_level.get(), make_tv<KindOfInt64>(error.level));
@@ -678,7 +683,7 @@ Array HHVM_FUNCTION(libxml_get_errors) {
678683
}
679684

680685
Variant HHVM_FUNCTION(libxml_get_last_error) {
681-
xmlErrorPtr error = xmlGetLastError();
686+
auto error = xmlGetLastError();
682687
if (error) {
683688
return create_libxmlerror(*error);
684689
}

hphp/runtime/ext/soap/sdl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static void load_wsdl_ex(char *struri, sdlCtx *ctx, bool include,
178178
wsdl = soap_xmlParseFile(struri);
179179
}
180180
if (!wsdl) {
181-
xmlErrorPtr xmlErrorPtr = xmlGetLastError();
181+
auto xmlErrorPtr = xmlGetLastError();
182182
if (xmlErrorPtr) {
183183
throw SoapException("Parsing WSDL: Couldn't load from '%s' : %s",
184184
struri, xmlErrorPtr->message);

0 commit comments

Comments
 (0)