From: Sara Golemon Date: Wed, 4 Jul 2007 05:05:32 +0000 (+0000) Subject: Fix behavior of empty($sxe->element) and empty($sxe['prop']) X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND~320 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f4713a9a981cd0207b44b7067367e516e73ebf0;p=php Fix behavior of empty($sxe->element) and empty($sxe['prop']) when used on empty elements properties (apply PHP emptiness rules) --- 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; + } } } }