diff --git a/ext/dom/documentfragment.c b/ext/dom/documentfragment.c index 74b7f073741e1..76870faedfa4c 100644 --- a/ext/dom/documentfragment.c +++ b/ext/dom/documentfragment.c @@ -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; } diff --git a/ext/dom/node.c b/ext/dom/node.c index 55d3e2445472c..ee14fd158fc45 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -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; } @@ -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; } diff --git a/ext/dom/parentnode/tree.c b/ext/dom/parentnode/tree.c index 9fb682910f071..f57fd1cc7335b 100644 --- a/ext/dom/parentnode/tree.c +++ b/ext/dom/parentnode/tree.c @@ -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; } diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 0593700d32016..1327cfad6604b 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -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: @@ -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; } } diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h index e4013e448ae26..7dd8cc896b48a 100644 --- a/ext/dom/php_dom.h +++ b/ext/dom/php_dom.h @@ -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);