Skip to content

Commit dbe897b

Browse files
committed
Remove useless readonly checks
These checks will always be false because we're dealing with elements here. DOMElement always are of type XML_ELEMENT_NODE, so they don't need to be checked.
1 parent c8964b9 commit dbe897b

File tree

1 file changed

+0
-57
lines changed

1 file changed

+0
-57
lines changed

ext/dom/element.c

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ static xmlAttrPtr dom_element_reflected_attribute_write(dom_object *obj, zval *n
167167
return NULL;
168168
}
169169

170-
if (dom_node_is_read_only(nodep) == SUCCESS) {
171-
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(obj->document));
172-
return NULL;
173-
}
174-
175170
/* Typed property, so it is a string already */
176171
ZEND_ASSERT(Z_TYPE_P(newval) == IS_STRING);
177172
return xmlSetNsProp(nodep, NULL, (const xmlChar *) name, (const xmlChar *) Z_STRVAL_P(newval));
@@ -395,11 +390,6 @@ PHP_METHOD(DOMElement, setAttribute)
395390

396391
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
397392

398-
if (dom_node_is_read_only(nodep) == SUCCESS) {
399-
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document));
400-
RETURN_FALSE;
401-
}
402-
403393
attr = dom_get_dom1_attribute(nodep, (xmlChar *)name);
404394
if (attr != NULL) {
405395
switch (attr->type) {
@@ -466,11 +456,6 @@ PHP_METHOD(DOMElement, removeAttribute)
466456

467457
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
468458

469-
if (dom_node_is_read_only(nodep) == SUCCESS) {
470-
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document));
471-
RETURN_FALSE;
472-
}
473-
474459
attrp = dom_get_dom1_attribute(nodep, (xmlChar *)name);
475460
if (attrp == NULL) {
476461
RETURN_FALSE;
@@ -533,11 +518,6 @@ PHP_METHOD(DOMElement, setAttributeNode)
533518

534519
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
535520

536-
if (dom_node_is_read_only(nodep) == SUCCESS) {
537-
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document));
538-
RETURN_FALSE;
539-
}
540-
541521
DOM_GET_OBJ(attrp, node, xmlAttrPtr, attrobj);
542522

543523
if (attrp->type != XML_ATTRIBUTE_NODE) {
@@ -599,11 +579,6 @@ PHP_METHOD(DOMElement, removeAttributeNode)
599579

600580
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
601581

602-
if (dom_node_is_read_only(nodep) == SUCCESS) {
603-
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document));
604-
RETURN_FALSE;
605-
}
606-
607582
DOM_GET_OBJ(attrp, node, xmlAttrPtr, attrobj);
608583

609584
if (attrp->type != XML_ATTRIBUTE_NODE || attrp->parent != nodep) {
@@ -748,11 +723,6 @@ PHP_METHOD(DOMElement, setAttributeNS)
748723

749724
stricterror = dom_get_strict_error(intern->document);
750725

751-
if (dom_node_is_read_only(elemp) == SUCCESS) {
752-
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, stricterror);
753-
RETURN_NULL();
754-
}
755-
756726
errorcode = dom_check_qname(name, &localname, &prefix, uri_len, name_len);
757727

758728
if (errorcode == 0) {
@@ -867,11 +837,6 @@ PHP_METHOD(DOMElement, removeAttributeNS)
867837

868838
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
869839

870-
if (dom_node_is_read_only(nodep) == SUCCESS) {
871-
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document));
872-
RETURN_NULL();
873-
}
874-
875840
attrp = xmlHasNsProp(nodep, (xmlChar *)name, (xmlChar *)uri);
876841

877842
nsptr = dom_get_nsdecl(nodep, (xmlChar *)name);
@@ -965,12 +930,6 @@ PHP_METHOD(DOMElement, setAttributeNodeNS)
965930
}
966931

967932
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
968-
969-
if (dom_node_is_read_only(nodep) == SUCCESS) {
970-
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document));
971-
RETURN_FALSE;
972-
}
973-
974933
DOM_GET_OBJ(attrp, node, xmlAttrPtr, attrobj);
975934

976935
/* ZPP Guarantees that a DOMAttr class is given, as it is converted to a xmlAttr
@@ -1145,11 +1104,6 @@ PHP_METHOD(DOMElement, setIdAttribute)
11451104

11461105
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
11471106

1148-
if (dom_node_is_read_only(nodep) == SUCCESS) {
1149-
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document));
1150-
RETURN_NULL();
1151-
}
1152-
11531107
attrp = xmlHasNsProp(nodep, (xmlChar *)name, NULL);
11541108
if (attrp == NULL || attrp->type == XML_ATTRIBUTE_DECL) {
11551109
php_dom_throw_error(NOT_FOUND_ERR, dom_get_strict_error(intern->document));
@@ -1181,11 +1135,6 @@ PHP_METHOD(DOMElement, setIdAttributeNS)
11811135

11821136
DOM_GET_OBJ(elemp, id, xmlNodePtr, intern);
11831137

1184-
if (dom_node_is_read_only(elemp) == SUCCESS) {
1185-
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document));
1186-
RETURN_NULL();
1187-
}
1188-
11891138
attrp = xmlHasNsProp(elemp, (xmlChar *)name, (xmlChar *)uri);
11901139
if (attrp == NULL || attrp->type == XML_ATTRIBUTE_DECL) {
11911140
php_dom_throw_error(NOT_FOUND_ERR, dom_get_strict_error(intern->document));
@@ -1214,12 +1163,6 @@ PHP_METHOD(DOMElement, setIdAttributeNode)
12141163
}
12151164

12161165
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
1217-
1218-
if (dom_node_is_read_only(nodep) == SUCCESS) {
1219-
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document));
1220-
RETURN_NULL();
1221-
}
1222-
12231166
DOM_GET_OBJ(attrp, node, xmlAttrPtr, attrobj);
12241167

12251168
if (attrp->parent != nodep) {

0 commit comments

Comments
 (0)