Fix GH-13764: xsl cannot build on PHP 8.4 (#13770)

Move some of the DOM APIs from the non-public php_dom.h header to the
public header xml_common.h.
This commit is contained in:
Niels Dossche 2024-03-20 19:03:09 +01:00 committed by GitHub
parent 4d51bfa270
commit e1630381b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 43 additions and 42 deletions

View file

@ -150,6 +150,8 @@ PHP 8.4 INTERNALS UPGRADE NOTES
value instead.
- Removed DOM_XMLNS_NAMESPACE from xml_common.h. Use DOM_XMLNS_NS_URI
from namespace_compat.h instead.
- Added php_dom_get_ns_mapper(), php_dom_next_in_tree_order(),
php_dom_follow_spec_doc_ref(), and php_dom_follow_spec_doc_ref().
b. ext/random
- The macro RAND_RANGE_BADSCALING() has been removed. The implementation

View file

@ -114,9 +114,6 @@ typedef enum _dom_iterator_type {
DOM_HTMLCOLLECTION,
} dom_iterator_type;
struct _php_dom_libxml_ns_mapper;
typedef struct _php_dom_libxml_ns_mapper php_dom_libxml_ns_mapper;
static inline dom_object_namespace_node *php_dom_namespace_node_obj_from_obj(zend_object *obj) {
return (dom_object_namespace_node*)((char*)(obj) - XtOffsetOf(dom_object_namespace_node, dom.std));
}
@ -178,27 +175,6 @@ void dom_document_convert_to_modern(php_libxml_ref_obj *document, xmlDocPtr lxml
dom_object *php_dom_instantiate_object_helper(zval *return_value, zend_class_entry *ce, xmlNodePtr obj, dom_object *parent);
xmlDocPtr php_dom_create_html_doc(void);
static zend_always_inline xmlNodePtr php_dom_next_in_tree_order(const xmlNode *nodep, const xmlNode *basep)
{
if (nodep->next) {
return nodep->next;
} else {
/* Go upwards, until we find a parent node with a next sibling, or until we hit the base. */
do {
nodep = nodep->parent;
if (nodep == basep) {
return NULL;
}
/* This shouldn't happen, unless there's an invalidation bug somewhere. */
if (UNEXPECTED(nodep == NULL)) {
zend_throw_error(NULL, "Current node in traversal is not in the document. Please report this as a bug in php-src.");
return NULL;
}
} while (nodep->next == NULL);
return nodep->next;
}
}
typedef enum {
DOM_LOAD_STRING = 0,
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
}
}
static zend_always_inline bool php_dom_follow_spec_doc_ref(const php_libxml_ref_obj *document)
{
return document != NULL && document->class_type == PHP_LIBXML_CLASS_MODERN;
}
static zend_always_inline bool php_dom_follow_spec_intern(const dom_object *intern)
{
ZEND_ASSERT(intern != NULL);
return php_dom_follow_spec_doc_ref(intern->document);
}
static zend_always_inline bool php_dom_follow_spec_node(const xmlNode *node)
{
ZEND_ASSERT(node != NULL);
@ -311,12 +276,6 @@ static zend_always_inline bool php_dom_follow_spec_node(const xmlNode *node)
return false;
}
static zend_always_inline php_dom_libxml_ns_mapper *php_dom_get_ns_mapper(dom_object *intern)
{
ZEND_ASSERT(intern->document != NULL);
return (php_dom_libxml_ns_mapper *) intern->document->private_data;
}
PHP_MINIT_FUNCTION(dom);
PHP_MSHUTDOWN_FUNCTION(dom);
PHP_MINFO_FUNCTION(dom);

View file

@ -80,4 +80,45 @@ PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj);
__id = ZEND_THIS; \
DOM_GET_OBJ(__ptr, __id, __prtype, __intern);
struct _php_dom_libxml_ns_mapper;
typedef struct _php_dom_libxml_ns_mapper php_dom_libxml_ns_mapper;
static zend_always_inline php_dom_libxml_ns_mapper *php_dom_get_ns_mapper(dom_object *intern)
{
ZEND_ASSERT(intern->document != NULL);
return (php_dom_libxml_ns_mapper *) intern->document->private_data;
}
static zend_always_inline xmlNodePtr php_dom_next_in_tree_order(const xmlNode *nodep, const xmlNode *basep)
{
if (nodep->next) {
return nodep->next;
} else {
/* Go upwards, until we find a parent node with a next sibling, or until we hit the base. */
do {
nodep = nodep->parent;
if (nodep == basep) {
return NULL;
}
/* This shouldn't happen, unless there's an invalidation bug somewhere. */
if (UNEXPECTED(nodep == NULL)) {
zend_throw_error(NULL, "Current node in traversal is not in the document. Please report this as a bug in php-src.");
return NULL;
}
} while (nodep->next == NULL);
return nodep->next;
}
}
static zend_always_inline bool php_dom_follow_spec_doc_ref(const php_libxml_ref_obj *document)
{
return document != NULL && document->class_type == PHP_LIBXML_CLASS_MODERN;
}
static zend_always_inline bool php_dom_follow_spec_intern(const dom_object *intern)
{
ZEND_ASSERT(intern != NULL);
return php_dom_follow_spec_doc_ref(intern->document);
}
#endif

View file

@ -23,7 +23,6 @@
#include "php_xsl.h"
#include <libxslt/variables.h>
#include "ext/libxml/php_libxml.h"
#include "ext/dom/php_dom.h"
#include "ext/dom/namespace_compat.h"