Skip to content

Commit 1754cdc

Browse files
iluuu1994ndossche
authored andcommitted
Suppress libxml deprecations
Closes GH-20538
1 parent 9f903fb commit 1754cdc

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

ext/dom/document.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,12 +1595,16 @@ PHP_METHOD(DOMDocument, save)
15951595
libxml_doc_props const* doc_props = dom_get_doc_props_read_only(intern->document);
15961596
bool format = doc_props->formatoutput;
15971597
if (options & LIBXML_SAVE_NOEMPTYTAG) {
1598+
ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
15981599
saveempty = xmlSaveNoEmptyTags;
15991600
xmlSaveNoEmptyTags = 1;
1601+
ZEND_DIAGNOSTIC_IGNORED_END
16001602
}
16011603
zend_long bytes = intern->document->handlers->dump_doc_to_file(file, docp, format, (const char *) docp->encoding);
16021604
if (options & LIBXML_SAVE_NOEMPTYTAG) {
1605+
ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
16031606
xmlSaveNoEmptyTags = saveempty;
1607+
ZEND_DIAGNOSTIC_IGNORED_END
16041608
}
16051609
if (bytes == -1) {
16061610
RETURN_FALSE;
@@ -1641,10 +1645,14 @@ static void dom_document_save_xml(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry
16411645

16421646
/* Save libxml2 global, override its value, and restore after saving (don't move me or risk breaking the state
16431647
* w.r.t. the implicit return in DOM_GET_OBJ). */
1648+
ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
16441649
old_xml_save_no_empty_tags = xmlSaveNoEmptyTags;
16451650
xmlSaveNoEmptyTags = (options & LIBXML_SAVE_NOEMPTYTAG) ? 1 : 0;
1651+
ZEND_DIAGNOSTIC_IGNORED_END
16461652
res = intern->document->handlers->dump_node_to_str(docp, node, format, (const char *) docp->encoding);
1653+
ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
16471654
xmlSaveNoEmptyTags = old_xml_save_no_empty_tags;
1655+
ZEND_DIAGNOSTIC_IGNORED_END
16481656
} else {
16491657
int converted_options = XML_SAVE_AS_XML;
16501658
if (options & XML_SAVE_NO_DECL) {
@@ -1655,10 +1663,14 @@ static void dom_document_save_xml(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry
16551663
}
16561664

16571665
/* Save libxml2 global, override its value, and restore after saving. */
1666+
ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
16581667
old_xml_save_no_empty_tags = xmlSaveNoEmptyTags;
16591668
xmlSaveNoEmptyTags = (options & LIBXML_SAVE_NOEMPTYTAG) ? 1 : 0;
1669+
ZEND_DIAGNOSTIC_IGNORED_END
16601670
res = intern->document->handlers->dump_doc_to_str(docp, converted_options, (const char *) docp->encoding);
1671+
ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
16611672
xmlSaveNoEmptyTags = old_xml_save_no_empty_tags;
1673+
ZEND_DIAGNOSTIC_IGNORED_END
16621674
}
16631675

16641676
if (!res) {

ext/dom/xml_serializer.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,10 @@ static int dom_xml_serialize_element_node(
10971097
/* 14. If ns is the HTML namespace, and the node's list of children is empty, and the node's localName matches
10981098
* any one of the following void elements: ... */
10991099
if (element->children == NULL) {
1100-
if (xmlSaveNoEmptyTags) {
1100+
ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
1101+
int saveNoEmptyTags = xmlSaveNoEmptyTags;
1102+
ZEND_DIAGNOSTIC_IGNORED_END
1103+
if (saveNoEmptyTags) {
11011104
/* Do nothing, use the <x></x> closing style. */
11021105
} else if (php_dom_ns_is_fast(element, php_dom_ns_is_html_magic_token)) {
11031106
size_t name_length = strlen((const char *) element->name);

ext/libxml/libxml.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,12 @@ static xmlParserInputPtr php_libxml_external_entity_loader(const char *URL,
813813
} else {
814814
/* make stream not being closed when the zval is freed */
815815
GC_ADDREF(stream->res);
816+
817+
ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
816818
pib->context = stream;
817819
pib->readcallback = php_libxml_streams_IO_read;
818820
pib->closecallback = php_libxml_streams_IO_close;
821+
ZEND_DIAGNOSTIC_IGNORED_END
819822

820823
ret = xmlNewIOInputStream(context, pib, enc);
821824
if (ret == NULL) {

0 commit comments

Comments
 (0)