Skip to content

Commit 85705ed

Browse files
committed
Fix compilation on libxml2 2.13
1 parent 0bd2602 commit 85705ed

File tree

7 files changed

+22
-7
lines changed

7 files changed

+22
-7
lines changed

ext/dom/document.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,11 +1429,13 @@ xmlDocPtr dom_document_parser(zval *id, dom_load_mode mode, const char *source,
14291429
if (keep_blanks == 0 && ! (options & XML_PARSE_NOBLANKS)) {
14301430
options |= XML_PARSE_NOBLANKS;
14311431
}
1432+
if (recover) {
1433+
options |= XML_PARSE_RECOVER;
1434+
}
14321435

14331436
php_libxml_sanitize_parse_ctxt_options(ctxt);
14341437
xmlCtxtUseOptions(ctxt, options);
14351438

1436-
ctxt->recovery = recover;
14371439
if (recover) {
14381440
old_error_reporting = EG(error_reporting);
14391441
EG(error_reporting) = old_error_reporting | E_WARNING;
@@ -1443,7 +1445,7 @@ xmlDocPtr dom_document_parser(zval *id, dom_load_mode mode, const char *source,
14431445

14441446
if (ctxt->wellFormed || recover) {
14451447
ret = ctxt->myDoc;
1446-
if (ctxt->recovery) {
1448+
if (recover) {
14471449
EG(error_reporting) = old_error_reporting;
14481450
}
14491451
/* If loading from memory, set the base reference uri for the document */

ext/libxml/libxml.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,10 @@ php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc)
544544
static xmlOutputBufferPtr
545545
php_libxml_output_buffer_create_filename(const char *URI,
546546
xmlCharEncodingHandlerPtr encoder,
547-
int compression ATTRIBUTE_UNUSED)
547+
int compression)
548548
{
549+
ZEND_IGNORE_VALUE(compression);
550+
549551
xmlOutputBufferPtr ret;
550552
xmlURIPtr puri;
551553
void *context = NULL;

ext/libxml/php_libxml.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,15 @@ ZEND_TSRMLS_CACHE_EXTERN()
258258
* Generally faster because no locking is involved, and this has the advantage that it sets the options to a known good value. */
259259
static zend_always_inline void php_libxml_sanitize_parse_ctxt_options(xmlParserCtxtPtr ctxt)
260260
{
261+
ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") \
261262
ctxt->loadsubset = 0;
262263
ctxt->validate = 0;
263264
ctxt->pedantic = 0;
264265
ctxt->replaceEntities = 0;
265266
ctxt->linenumbers = 0;
266267
ctxt->keepBlanks = 1;
267268
ctxt->options = 0;
269+
ZEND_DIAGNOSTIC_IGNORED_END
268270
}
269271

270272
#else /* HAVE_LIBXML */

ext/soap/php_xml.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,16 @@ xmlDocPtr soap_xmlParseFile(const char *filename)
9292
bool old;
9393

9494
php_libxml_sanitize_parse_ctxt_options(ctxt);
95+
/* TODO: In libxml2 2.14.0 change this to the new options API so we don't rely on deprecated APIs. */
96+
ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
9597
ctxt->keepBlanks = 0;
98+
ctxt->options |= XML_PARSE_HUGE;
99+
ZEND_DIAGNOSTIC_IGNORED_END
96100
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
97101
ctxt->sax->comment = soap_Comment;
98102
ctxt->sax->warning = NULL;
99103
ctxt->sax->error = NULL;
100104
/*ctxt->sax->fatalError = NULL;*/
101-
ctxt->options |= XML_PARSE_HUGE;
102105
old = php_libxml_disable_entity_loader(1);
103106
xmlParseDocument(ctxt);
104107
php_libxml_disable_entity_loader(old);
@@ -146,7 +149,10 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
146149
ctxt->sax->warning = NULL;
147150
ctxt->sax->error = NULL;
148151
/*ctxt->sax->fatalError = NULL;*/
152+
/* TODO: In libxml2 2.14.0 change this to the new options API so we don't rely on deprecated APIs. */
153+
ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
149154
ctxt->options |= XML_PARSE_HUGE;
155+
ZEND_DIAGNOSTIC_IGNORED_END
150156
old = php_libxml_disable_entity_loader(1);
151157
xmlParseDocument(ctxt);
152158
php_libxml_disable_entity_loader(old);

ext/xml/compat.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,7 @@ XML_GetCurrentByteCount(XML_Parser parser)
710710
{
711711
/* WARNING: this is identical to ByteIndex; it should probably
712712
* be different */
713-
return parser->parser->input->consumed +
714-
(parser->parser->input->cur - parser->parser->input->base);
713+
return XML_GetCurrentByteIndex(parser);
715714
}
716715

717716
PHP_XML_API const XML_Char *XML_ExpatVersion(void)

ext/xml/xml.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ static int xml_parse_helper(xml_parser *parser, const char *data, size_t data_le
271271

272272
/* libxml2 specific options */
273273
#ifdef LIBXML_EXPAT_COMPAT
274+
/* TODO: In libxml2 2.14.0 change this to the new options API so we don't rely on deprecated APIs. */
275+
ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
274276
/* See xmlInitSAXParserCtxt() and xmlCtxtUseOptions() */
275277
if (parser->parsehuge) {
276278
parser->parser->parser->options |= XML_PARSE_HUGE;
@@ -279,6 +281,7 @@ static int xml_parse_helper(xml_parser *parser, const char *data, size_t data_le
279281
parser->parser->parser->options &= ~XML_PARSE_HUGE;
280282
xmlDictSetLimit(parser->parser->parser->dict, XML_MAX_DICTIONARY_LIMIT);
281283
}
284+
ZEND_DIAGNOSTIC_IGNORED_END
282285
#endif
283286

284287
parser->isparsing = 1;

ext/xmlwriter/php_xmlwriter.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,8 @@ static void php_xmlwriter_flush(INTERNAL_FUNCTION_PARAMETERS, int force_string)
10091009
}
10101010
output_bytes = xmlTextWriterFlush(ptr);
10111011
if (buffer) {
1012-
RETVAL_STRING((char *) buffer->content);
1012+
const xmlChar *content = xmlBufferContent(buffer);
1013+
RETVAL_STRING((const char *) content);
10131014
if (empty) {
10141015
xmlBufferEmpty(buffer);
10151016
}

0 commit comments

Comments
 (0)