Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 0 additions & 41 deletions ext/dom/php_dom.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
41 changes: 41 additions & 0 deletions ext/dom/xml_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion ext/xsl/xsltprocessor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down