Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ PHP NEWS
an object converted to an array fails. (David Carlier)
. Fixed read buffer compaction in php_stream_filter_flush(). (crystarm)

- SimpleXML:
. Fixed writing to a dimension of the object returned by attributes() not
creating the attribute. (iliaal)

- Zip:
. Fixed bug GH-23276 (ZipArchive subclass storing its own stream cannot be
garbage collected). (Weilin Du, ndossche)
Expand Down
3 changes: 1 addition & 2 deletions ext/simplexml/simplexml.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,7 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value,
if (sxe->iter.type == SXE_ITER_ATTRLIST) {
attribs = 1;
elements = 0;
node = php_sxe_get_first_node_non_destructive(sxe, node);
attr = (xmlAttrPtr)node;
attr = (xmlAttrPtr)php_sxe_get_first_node_non_destructive(sxe, node);
test = sxe->iter.name != NULL;
} else if (sxe->iter.type != SXE_ITER_CHILD) {
mynode = node;
Expand Down
30 changes: 30 additions & 0 deletions ext/simplexml/tests/attributes_dimension_write.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Creating new attributes via dimension and property writes on attributes()
--FILE--
<?php
$x = simplexml_load_string('<r a="1"/>');
$x->attributes()['new'] = 'v';
echo $x->asXML();

$a = simplexml_load_string('<r/>');
$a->attributes()['created'] = 'yes';
echo $a->asXML();

$b = simplexml_load_string('<r a="1"/>');
$attrs = $b->attributes();
$attrs->other = 2;
echo $b->asXML();

$c = simplexml_load_string('<r a="1"/>');
$c->attributes()['a'] = '2';
echo $c->asXML();
?>
--EXPECT--
<?xml version="1.0"?>
<r a="1" new="v"/>
<?xml version="1.0"?>
<r created="yes"/>
<?xml version="1.0"?>
<r a="1" other="2"/>
<?xml version="1.0"?>
<r a="2"/>
Loading