summaryrefslogtreecommitdiff
path: root/ext/simplexml/simplexml.c
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2007-03-26 20:14:58 +0000
committerRob Richards <rrichards@php.net>2007-03-26 20:14:58 +0000
commitb7c2eb3228ca3eaed09b3c1647ccf5623c9c11b3 (patch)
tree310ed4e370663bf7f94bf0f63ef15d30ce29f579 /ext/simplexml/simplexml.c
parent7053b8907247cd3df4a96409a8a811c2fb4015f5 (diff)
downloadphp-git-b7c2eb3228ca3eaed09b3c1647ccf5623c9c11b3.tar.gz
fix bug #37386 (autocreating element doesn't assign value to first node)
all single SimpleXMLElements are addressable using offset 0 use correct node for xpath context node add test
Diffstat (limited to 'ext/simplexml/simplexml.c')
-rw-r--r--ext/simplexml/simplexml.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 8787e542a1..2c919ea24f 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -138,7 +138,14 @@ static xmlNodePtr sxe_get_element_by_offset(php_sxe_object *sxe, long offset, xm
long nodendx = 0;
if (sxe->iter.type == SXE_ITER_NONE) {
- return NULL;
+ if (offset == 0) {
+ if (cnt) {
+ *cnt = 0;
+ }
+ return node;
+ } else {
+ return NULL;
+ }
}
while (node && nodendx <= offset) {
SKIP_TEXT(node)
@@ -429,7 +436,7 @@ static void sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_boo
int nodendx = 0;
int test = 0;
int new_value = 0;
- long cnt;
+ long cnt = 0;
zval tmp_zv, trim_zv, value_copy;
if (!member) {
@@ -1122,9 +1129,11 @@ SXE_METHOD(xpath)
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement((xmlDocPtr) sxe->document->ptr), NULL TSRMLS_CC);
}
- sxe->xpath->node = sxe->node->node;
+ nodeptr = php_sxe_get_first_node(sxe, sxe->node->node TSRMLS_CC);
+
+ sxe->xpath->node = nodeptr;
- ns = xmlGetNsList((xmlDocPtr) sxe->document->ptr, (xmlNodePtr) sxe->node->node);
+ ns = xmlGetNsList((xmlDocPtr) sxe->document->ptr, nodeptr);
if (ns != NULL) {
while (ns[nsnbr] != NULL) {
nsnbr++;