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

ext/simplexml/simplexml.c

index 3ba14255abd76ae2a61643564c333116f119d9c1..9b60779b6f5d4d1d05af05b309087b9bf14c72ab 100644 (file)
@@ -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;
+                               }
                        }
                }
        }