Skip to content

Commit

Permalink
Fix libxml and soap extension with libxml >= 2.12.0 (#9572)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mszabo-wikia authored and facebook-github-bot committed Jan 9, 2025
1 parent b38b525 commit 569e268
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions hphp/runtime/ext/libxml/ext_libxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <libxml/uri.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlsave.h>
#include <libxml/xmlversion.h>
#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/relaxng.h>
#include <libxml/xmlschemas.h>
Expand Down Expand Up @@ -624,7 +625,11 @@ String libxml_get_valid_file_path(const String& source) {
return file_dest;
}

#if LIBXML_VERSION >= 21200
static void libxml_error_handler(void* /*userData*/, const xmlError* error) {
#else
static void libxml_error_handler(void* /*userData*/, xmlErrorPtr error) {
#endif
if (rl_libxml_request_data->m_suppress_error) {
return;
}
Expand All @@ -642,7 +647,7 @@ static void libxml_error_handler(void* /*userData*/, xmlErrorPtr error) {
}
}

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

Variant HHVM_FUNCTION(libxml_get_last_error) {
xmlErrorPtr error = xmlGetLastError();
auto error = xmlGetLastError();
if (error) {
return create_libxmlerror(*error);
}
Expand Down
2 changes: 1 addition & 1 deletion hphp/runtime/ext/soap/sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static void load_wsdl_ex(char *struri, sdlCtx *ctx, bool include,
wsdl = soap_xmlParseFile(struri);
}
if (!wsdl) {
xmlErrorPtr xmlErrorPtr = xmlGetLastError();
auto xmlErrorPtr = xmlGetLastError();
if (xmlErrorPtr) {
throw SoapException("Parsing WSDL: Couldn't load from '%s' : %s",
struri, xmlErrorPtr->message);
Expand Down

0 comments on commit 569e268

Please sign in to comment.