summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSara Golemon <pollita@php.net>2007-07-04 05:05:32 +0000
committerSara Golemon <pollita@php.net>2007-07-04 05:05:32 +0000
commit2f4713a9a981cd0207b44b7067367e516e73ebf0 (patch)
tree9e6e5d0d0987be321eb53b47432c9c781c9a255c
parent64497da24279d20706537396d3f228376774348b (diff)
downloadphp-git-2f4713a9a981cd0207b44b7067367e516e73ebf0.tar.gz
Fix behavior of empty($sxe->element) and empty($sxe['prop'])
when used on empty elements properties (apply PHP emptiness rules)
-rw-r--r--ext/simplexml/simplexml.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 3ba14255ab..9b60779b6f 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -797,6 +797,11 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend
attr = attr->next;
}
}
+ if (exists && check_empty == 1 &&
+ (!attr->children || !attr->children->content || !attr->children->content[0] || !xmlStrcmp(attr->children->content, "0")) ) {
+ /* Attribute with no content in it's text node */
+ exists = 0;
+ }
}
if (elements) {
@@ -819,6 +824,11 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend
}
if (node) {
exists = 1;
+ if (check_empty == 1 &&
+ (!node->children || (node->children->type == XML_TEXT_NODE && !node->children->next &&
+ (!node->children->content || !node->children->content[0] || !xmlStrcmp(node->children->content, "0")))) ) {
+ exists = 0;
+ }
}
}
}