php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60126 Assigning node value results inserting selected node.
Submitted: 2011-10-25 01:56 UTC Modified: 2011-10-25 04:15 UTC
From: yohgaki at ohgaki dot net Assigned:
Status: Closed Package: SimpleXML related
PHP Version: 5.3.8 OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: yohgaki at ohgaki dot net
New email:
PHP Version: OS:

 

 [2011-10-25 01:56 UTC] 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>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-25 01:58 UTC] yohgaki at ohgaki dot net
Oops. I swapped Expected and Actual result, but I'm sure that you get the idea.
 [2011-10-25 04:15 UTC] yohgaki at ohgaki dot net
-Status: Open +Status: Closed
 [2011-10-25 04:15 UTC] yohgaki at ohgaki dot net
Bogus. Forgot to ignore root node.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 20:01:30 2024 UTC