From:             
Operating system: any
PHP version:      5.3.8
Package:          SimpleXML related
Bug Type:         Bug
Bug description:Assigning node value results inserting selected node.

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 bug report at https://bugs.php.net/bug.php?id=60126&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=60126&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=60126&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=60126&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=60126&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=60126&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=60126&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=60126&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=60126&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=60126&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=60126&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=60126&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=60126&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=60126&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=60126&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=60126&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=60126&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=60126&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=60126&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=60126&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=60126&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=60126&r=mysqlcfg

Reply via email to