From: Sara Golemon Date: Wed, 4 Jul 2007 05:05:57 +0000 (+0000) Subject: MFH (r-1.240) X-Git-Tag: php-5.2.4RC1~235 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ac512f5479d4e966905b2e7d72f5cefac10d716;p=php MFH (r-1.240) Fix behavior of empty($sxe->element) and empty($sxe['prop']) when used on empty elements properties (apply PHP emptiness rules) --- diff --git a/NEWS b/NEWS index 8c89f37e69..8bda0a6e2a 100644 --- a/NEWS +++ b/NEWS @@ -37,6 +37,7 @@ PHP NEWS (Ilia) - Fixed INFILE LOCAL option handling with MySQL extensions not to be allowed when open_basedir or safe_mode is active. (Stas) +- Faxed SimpleXML's behavior when used with empty(). (Sara) - Fixed PECL Bug #11345 (PDO_OCI crash after National language Support "NLS" environment initialization error) (Chris Jones) diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 04fc95ea06..c6e2358cc5 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -787,6 +787,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) { @@ -809,6 +814,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; + } } } }