Skip to content

Commit c5f4c3d

Browse files
committed
[ci-skip] Merge branch 'PHP-8.0'
2 parents 70df89e + 665e1f3 commit c5f4c3d

File tree

3 files changed

+17
-38
lines changed

3 files changed

+17
-38
lines changed

ext/dom/characterdata.c

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -349,48 +349,16 @@ PHP_METHOD(DOMCharacterData, replaceData)
349349
PHP_METHOD(DOMCharacterData, remove)
350350
{
351351
zval *id = ZEND_THIS;
352-
xmlNodePtr children, child;
352+
xmlNodePtr child;
353353
dom_object *intern;
354-
int stricterror;
355354

356355
if (zend_parse_parameters_none() == FAILURE) {
357356
RETURN_THROWS();
358357
}
359358

360359
DOM_GET_OBJ(child, id, xmlNodePtr, intern);
361360

362-
if (dom_node_children_valid(child) == FAILURE) {
363-
RETURN_NULL();
364-
}
365-
366-
stricterror = dom_get_strict_error(intern->document);
367-
368-
if (dom_node_is_read_only(child) == SUCCESS ||
369-
(child->parent != NULL && dom_node_is_read_only(child->parent) == SUCCESS)) {
370-
php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, stricterror);
371-
RETURN_NULL();
372-
}
373-
374-
if (!child->parent) {
375-
php_dom_throw_error(NOT_FOUND_ERR, stricterror);
376-
RETURN_NULL();
377-
}
378-
379-
children = child->parent->children;
380-
if (!children) {
381-
php_dom_throw_error(NOT_FOUND_ERR, stricterror);
382-
RETURN_NULL();
383-
}
384-
385-
while (children) {
386-
if (children == child) {
387-
xmlUnlinkNode(child);
388-
RETURN_NULL();
389-
}
390-
children = children->next;
391-
}
392-
393-
php_dom_throw_error(NOT_FOUND_ERR, stricterror);
361+
dom_child_node_remove(intern);
394362
RETURN_NULL();
395363
}
396364

ext/dom/parentnode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,6 @@ void dom_child_node_remove(dom_object *context)
374374
xmlNodePtr children;
375375
int stricterror;
376376

377-
if (dom_node_children_valid(child) == FAILURE) {
378-
return;
379-
}
380-
381377
stricterror = dom_get_strict_error(context->document);
382378

383379
if (dom_node_is_read_only(child) == SUCCESS ||
@@ -391,6 +387,10 @@ void dom_child_node_remove(dom_object *context)
391387
return;
392388
}
393389

390+
if (dom_node_children_valid(child->parent) == FAILURE) {
391+
return;
392+
}
393+
394394
children = child->parent->children;
395395
if (!children) {
396396
php_dom_throw_error(NOT_FOUND_ERR, stricterror);

ext/dom/tests/bug80600.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
dom: DOMChildNode::remove does not work on character data
3+
--FILE--
4+
<?php
5+
6+
$doc = new \DOMDocument();
7+
$doc->loadXML('<a><!-- foo --></a>');
8+
$doc->documentElement->firstChild->remove();
9+
echo $doc->saveXML($doc->documentElement);
10+
--EXPECTF--
11+
<a/>

0 commit comments

Comments
 (0)