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
Type: Bug
Package: SimpleXML related
Operating System: any
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
Oops. I swapped Expected and Actual result, but I'm sure that you get the idea.
Previous Comments:
------------------------------------------------------------------------
[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