Bug #60126 [Opn->Csd]: Assigning node value results inserting selected node.
| From: | yohgaki at ohgaki dot net | Date: | Tue, 25 Oct 2011 04:15:21 +0000 |
| Subject: | Bug #60126 [Opn->Csd]: Assigning node value results inserting selected node. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-164545@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60126&edit=1
ID: 60126
User updated by: yohgaki at ohgaki dot net
Reported by: yohgaki at ohgaki dot net
Summary: Assigning node value results inserting selected
node.
-Status: Open
+Status: Closed
Type: Bug
Package: SimpleXML related
Operating System: any
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
Bogus. Forgot to ignore root node.
Previous Comments:
------------------------------------------------------------------------
[2011-10-25 01:58:53] yohgaki at ohgaki dot net
Oops. I swapped Expected and Actual result, but I'm sure that you get the idea.
------------------------------------------------------------------------
[2011-10-25 01:56:29] yohgaki at ohgaki dot net
Description:
------------
Updating node value result inserting selected node.
PHP should update value, NOT inserting selected node.
This bug is located at ext/simplexml.c
static int sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool
elements, zend_bool attribs, xmlNodePtr *pnewnode TSRMLS_DC)
It seems the logic is broken for this case.
Test script:
---------------
<?php
$string = <<<XML
<?xml version="1.0" ?>
<root>
<node>
value
</node>
</root>
XML;
$xml = simplexml_load_string($string);
$xml->root->node = "NEW VALUE";
print $xml->asXML();
Expected result:
----------------
<?xml version="1.0"?>
<root>
<node>
value
</node>
<root><node>NEW VALUE</node></root></root>
Actual result:
--------------
<?xml version="1.0"?>
<root>
<node>
NEW VALUE
</node>
</root>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60126&edit=1