]> granicus.if.org Git - php/commitdiff
MFH (r-1.240)
authorSara Golemon <pollita@php.net>
Wed, 4 Jul 2007 05:05:57 +0000 (05:05 +0000)
committerSara Golemon <pollita@php.net>
Wed, 4 Jul 2007 05:05:57 +0000 (05:05 +0000)
Fix behavior of empty($sxe->element) and empty($sxe['prop'])
when used on empty elements properties (apply PHP emptiness rules)

NEWS
ext/simplexml/simplexml.c

diff --git a/NEWS b/NEWS
index 8c89f37e690417812a39f5dd0eb5d6d83b446031..8bda0a6e2a12a53006618065f8dd151a02dad2d1 100644 (file)
--- 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)
index 04fc95ea06c3d8aa47336f3fe9e003b6c6578147..c6e2358cc54bfde7c00c5990d1628e36631e2f5c 100644 (file)
@@ -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;
+                               }
                        }
                }
        }