Skip to content

Commit c2ccc96

Browse files
committed
Fix phpGH-13764: xsl cannot build on PHP 8.4
Move some of the DOM APIs from the non-public php_dom.h header to the public header xml_common.h.
1 parent 807524d commit c2ccc96

File tree

4 files changed

+43
-42
lines changed

4 files changed

+43
-42
lines changed

UPGRADING.INTERNALS

+2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ PHP 8.4 INTERNALS UPGRADE NOTES
150150
value instead.
151151
- Removed DOM_XMLNS_NAMESPACE from xml_common.h. Use DOM_XMLNS_NS_URI
152152
from namespace_compat.h instead.
153+
- Added php_dom_get_ns_mapper(), php_dom_next_in_tree_order(),
154+
php_dom_follow_spec_doc_ref(), and php_dom_follow_spec_doc_ref().
153155

154156
b. ext/random
155157
- The macro RAND_RANGE_BADSCALING() has been removed. The implementation

ext/dom/php_dom.h

-41
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ typedef enum _dom_iterator_type {
114114
DOM_HTMLCOLLECTION,
115115
} dom_iterator_type;
116116

117-
struct _php_dom_libxml_ns_mapper;
118-
typedef struct _php_dom_libxml_ns_mapper php_dom_libxml_ns_mapper;
119-
120117
static inline dom_object_namespace_node *php_dom_namespace_node_obj_from_obj(zend_object *obj) {
121118
return (dom_object_namespace_node*)((char*)(obj) - XtOffsetOf(dom_object_namespace_node, dom.std));
122119
}
@@ -178,27 +175,6 @@ void dom_document_convert_to_modern(php_libxml_ref_obj *document, xmlDocPtr lxml
178175
dom_object *php_dom_instantiate_object_helper(zval *return_value, zend_class_entry *ce, xmlNodePtr obj, dom_object *parent);
179176
xmlDocPtr php_dom_create_html_doc(void);
180177

181-
static zend_always_inline xmlNodePtr php_dom_next_in_tree_order(const xmlNode *nodep, const xmlNode *basep)
182-
{
183-
if (nodep->next) {
184-
return nodep->next;
185-
} else {
186-
/* Go upwards, until we find a parent node with a next sibling, or until we hit the base. */
187-
do {
188-
nodep = nodep->parent;
189-
if (nodep == basep) {
190-
return NULL;
191-
}
192-
/* This shouldn't happen, unless there's an invalidation bug somewhere. */
193-
if (UNEXPECTED(nodep == NULL)) {
194-
zend_throw_error(NULL, "Current node in traversal is not in the document. Please report this as a bug in php-src.");
195-
return NULL;
196-
}
197-
} while (nodep->next == NULL);
198-
return nodep->next;
199-
}
200-
}
201-
202178
typedef enum {
203179
DOM_LOAD_STRING = 0,
204180
DOM_LOAD_FILE = 1,
@@ -287,17 +263,6 @@ static zend_always_inline void php_dom_mark_cache_tag_up_to_date_from_node(php_l
287263
}
288264
}
289265

290-
static zend_always_inline bool php_dom_follow_spec_doc_ref(const php_libxml_ref_obj *document)
291-
{
292-
return document != NULL && document->class_type == PHP_LIBXML_CLASS_MODERN;
293-
}
294-
295-
static zend_always_inline bool php_dom_follow_spec_intern(const dom_object *intern)
296-
{
297-
ZEND_ASSERT(intern != NULL);
298-
return php_dom_follow_spec_doc_ref(intern->document);
299-
}
300-
301266
static zend_always_inline bool php_dom_follow_spec_node(const xmlNode *node)
302267
{
303268
ZEND_ASSERT(node != NULL);
@@ -311,12 +276,6 @@ static zend_always_inline bool php_dom_follow_spec_node(const xmlNode *node)
311276
return false;
312277
}
313278

314-
static zend_always_inline php_dom_libxml_ns_mapper *php_dom_get_ns_mapper(dom_object *intern)
315-
{
316-
ZEND_ASSERT(intern->document != NULL);
317-
return (php_dom_libxml_ns_mapper *) intern->document->private_data;
318-
}
319-
320279
PHP_MINIT_FUNCTION(dom);
321280
PHP_MSHUTDOWN_FUNCTION(dom);
322281
PHP_MINFO_FUNCTION(dom);

ext/dom/xml_common.h

+41
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,45 @@ PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj);
8080
__id = ZEND_THIS; \
8181
DOM_GET_OBJ(__ptr, __id, __prtype, __intern);
8282

83+
struct _php_dom_libxml_ns_mapper;
84+
typedef struct _php_dom_libxml_ns_mapper php_dom_libxml_ns_mapper;
85+
86+
static zend_always_inline php_dom_libxml_ns_mapper *php_dom_get_ns_mapper(dom_object *intern)
87+
{
88+
ZEND_ASSERT(intern->document != NULL);
89+
return (php_dom_libxml_ns_mapper *) intern->document->private_data;
90+
}
91+
92+
static zend_always_inline xmlNodePtr php_dom_next_in_tree_order(const xmlNode *nodep, const xmlNode *basep)
93+
{
94+
if (nodep->next) {
95+
return nodep->next;
96+
} else {
97+
/* Go upwards, until we find a parent node with a next sibling, or until we hit the base. */
98+
do {
99+
nodep = nodep->parent;
100+
if (nodep == basep) {
101+
return NULL;
102+
}
103+
/* This shouldn't happen, unless there's an invalidation bug somewhere. */
104+
if (UNEXPECTED(nodep == NULL)) {
105+
zend_throw_error(NULL, "Current node in traversal is not in the document. Please report this as a bug in php-src.");
106+
return NULL;
107+
}
108+
} while (nodep->next == NULL);
109+
return nodep->next;
110+
}
111+
}
112+
113+
static zend_always_inline bool php_dom_follow_spec_doc_ref(const php_libxml_ref_obj *document)
114+
{
115+
return document != NULL && document->class_type == PHP_LIBXML_CLASS_MODERN;
116+
}
117+
118+
static zend_always_inline bool php_dom_follow_spec_intern(const dom_object *intern)
119+
{
120+
ZEND_ASSERT(intern != NULL);
121+
return php_dom_follow_spec_doc_ref(intern->document);
122+
}
123+
83124
#endif

ext/xsl/xsltprocessor.c

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "php_xsl.h"
2424
#include <libxslt/variables.h>
2525
#include "ext/libxml/php_libxml.h"
26-
#include "ext/dom/php_dom.h"
2726
#include "ext/dom/namespace_compat.h"
2827

2928

0 commit comments

Comments
 (0)