File tree Expand file tree Collapse file tree 3 files changed +17
-38
lines changed Expand file tree Collapse file tree 3 files changed +17
-38
lines changed Original file line number Diff line number Diff line change @@ -349,48 +349,16 @@ PHP_METHOD(DOMCharacterData, replaceData)
349
349
PHP_METHOD (DOMCharacterData , remove )
350
350
{
351
351
zval * id = ZEND_THIS ;
352
- xmlNodePtr children , child ;
352
+ xmlNodePtr child ;
353
353
dom_object * intern ;
354
- int stricterror ;
355
354
356
355
if (zend_parse_parameters_none () == FAILURE ) {
357
356
RETURN_THROWS ();
358
357
}
359
358
360
359
DOM_GET_OBJ (child , id , xmlNodePtr , intern );
361
360
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 );
394
362
RETURN_NULL ();
395
363
}
396
364
Original file line number Diff line number Diff line change @@ -374,10 +374,6 @@ void dom_child_node_remove(dom_object *context)
374
374
xmlNodePtr children ;
375
375
int stricterror ;
376
376
377
- if (dom_node_children_valid (child ) == FAILURE ) {
378
- return ;
379
- }
380
-
381
377
stricterror = dom_get_strict_error (context -> document );
382
378
383
379
if (dom_node_is_read_only (child ) == SUCCESS ||
@@ -391,6 +387,10 @@ void dom_child_node_remove(dom_object *context)
391
387
return ;
392
388
}
393
389
390
+ if (dom_node_children_valid (child -> parent ) == FAILURE ) {
391
+ return ;
392
+ }
393
+
394
394
children = child -> parent -> children ;
395
395
if (!children ) {
396
396
php_dom_throw_error (NOT_FOUND_ERR , stricterror );
Original file line number Diff line number Diff line change
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/>
You can’t perform that action at this time.
0 commit comments