Skip to content

Change dom_node_is_read_only() to return bool #16757

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
Nov 11, 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: 1 addition & 1 deletion ext/dom/documentfragment.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ PHP_METHOD(DOMDocumentFragment, appendXML) {

DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);

if (dom_node_is_read_only(nodep) == SUCCESS) {
if (dom_node_is_read_only(nodep)) {
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document));
RETURN_FALSE;
}
Expand Down
8 changes: 4 additions & 4 deletions ext/dom/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,8 +837,8 @@ static xmlNodePtr dom_insert_fragment(xmlNodePtr nodep, xmlNodePtr prevsib, xmlN

static bool dom_node_check_legacy_insertion_validity(xmlNodePtr parentp, xmlNodePtr child, bool stricterror, bool warn_empty_fragment)
{
if (dom_node_is_read_only(parentp) == SUCCESS ||
(child->parent != NULL && dom_node_is_read_only(child->parent) == SUCCESS)) {
if (dom_node_is_read_only(parentp) ||
(child->parent != NULL && dom_node_is_read_only(child->parent))) {
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, stricterror);
return false;
}
Expand Down Expand Up @@ -1279,8 +1279,8 @@ static void dom_node_remove_child(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry
RETURN_FALSE;
}

if (dom_node_is_read_only(nodep) == SUCCESS ||
(child->parent != NULL && dom_node_is_read_only(child->parent) == SUCCESS)) {
if (dom_node_is_read_only(nodep) ||
(child->parent != NULL && dom_node_is_read_only(child->parent))) {
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, stricterror);
RETURN_FALSE;
}
Expand Down
4 changes: 2 additions & 2 deletions ext/dom/parentnode/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,8 @@ void dom_parent_node_before(dom_object *context, zval *nodes, uint32_t nodesc)

static zend_result dom_child_removal_preconditions(const xmlNode *child, const dom_object *context)
{
if (dom_node_is_read_only(child) == SUCCESS ||
(child->parent != NULL && dom_node_is_read_only(child->parent) == SUCCESS)) {
if (dom_node_is_read_only(child) ||
(child->parent != NULL && dom_node_is_read_only(child->parent))) {
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(context->document));
return FAILURE;
}
Expand Down
11 changes: 3 additions & 8 deletions ext/dom/php_dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ typedef struct dom_prop_handler {
dom_write_t write_func;
} dom_prop_handler;

int dom_node_is_read_only(const xmlNode *node) {
bool dom_node_is_read_only(const xmlNode *node) {
switch (node->type) {
case XML_ENTITY_REF_NODE:
case XML_ENTITY_NODE:
Expand All @@ -166,14 +166,9 @@ int dom_node_is_read_only(const xmlNode *node) {
case XML_ATTRIBUTE_DECL:
case XML_ENTITY_DECL:
case XML_NAMESPACE_DECL:
return SUCCESS;
break;
return true;
default:
if (node->doc == NULL) {
return SUCCESS;
} else {
return FAILURE;
}
return node->doc == NULL;
}
}

Expand Down
2 changes: 1 addition & 1 deletion ext/dom/php_dom.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ xmlNode *dom_get_elements_by_tag_name_ns_raw(xmlNodePtr basep, xmlNodePtr nodep,
void php_dom_create_implementation(zval *retval, bool modern);
int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child);
bool dom_has_feature(zend_string *feature, zend_string *version);
int dom_node_is_read_only(const xmlNode *node);
bool dom_node_is_read_only(const xmlNode *node);
bool dom_node_children_valid(const xmlNode *node);
void php_dom_create_iterator(zval *return_value, dom_iterator_type iterator_type, bool modern);
void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xmlHashTablePtr ht, const char *local, size_t local_len, const char *ns, size_t ns_len);
Expand Down