cvs: ZendEngine2(PHP_5_3) / zend_builtin_functions.c /tests 011.phpt bug42211.phpt

"Felipe Pena" <[email protected]>
Newsgroups gmane.comp.php.cvs.zend
Message-ID <cvsfelipe1219081442@cvsserver>
felipe		Mon Aug 18 17:44:02 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /ZendEngine2	zend_builtin_functions.c 
    /ZendEngine2/tests	011.phpt bug42211.phpt 
  Log:
  - MFH: Fixed bug #45743 (property_exists fails to find static protected member in child class)
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_builtin_functions.c?r1=1.277.2.12.2.25.2.27&r2=1.277.2.12.2.25.2.28&diff_format=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.27 ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.28
--- ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.27	Sat Aug  2 04:46:05 2008
+++ ZendEngine2/zend_builtin_functions.c	Mon Aug 18 17:44:02 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_builtin_functions.c,v 1.277.2.12.2.25.2.27 2008/08/02 04:46:05 felipe Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.277.2.12.2.25.2.28 2008/08/18 17:44:02 felipe Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -1215,8 +1215,8 @@
 	int property_len;
 	zend_class_entry *ce, **pce;
 	zend_property_info *property_info;
-	char *prop_name, *class_name;
 	zval property_z;
+	ulong h;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &object, &property, &property_len) == FAILURE) {
 		return;
@@ -1226,52 +1226,34 @@
 		RETURN_FALSE;
 	}
 
-	ZVAL_STRINGL(&property_z, property, property_len, 0);
-
-	switch(Z_TYPE_P(object)) {
-	case IS_STRING:
-		if (!Z_STRLEN_P(object)) {
-			RETURN_FALSE;
-		}
-		if (zend_lookup_class(Z_STRVAL_P(object), Z_STRLEN_P(object), &pce TSRMLS_CC) == SUCCESS) {
-			ce = *pce;
-		} else {
-			RETURN_FALSE;
-		}
-		if (!ce) {
-			RETURN_NULL();
-		}
-		if (!(property_info = zend_get_property_info(ce, &property_z, 1 TSRMLS_CC)) || property_info == &EG(std_property_info)) {
+	if (Z_TYPE_P(object) == IS_STRING) {
+		if (zend_lookup_class(Z_STRVAL_P(object), Z_STRLEN_P(object), &pce TSRMLS_CC) == FAILURE) {
 			RETURN_FALSE;
 		}
-		if (property_info->flags & ZEND_ACC_PUBLIC) {
-			RETURN_TRUE;
-		}
-		zend_unmangle_property_name(property_info->name, property_info->name_length, &class_name, &prop_name);
-		if (!strncmp(class_name, "*", 1)) {
-			if (instanceof_function(EG(scope), ce TSRMLS_CC) ||
-				(EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC))) {
-				RETURN_TRUE;
-			}
+		ce = *pce;
+	} else if (Z_TYPE_P(object) == IS_OBJECT) {
+		ce = Z_OBJCE_P(object);
+	} else {
+		zend_error(E_WARNING, "First parameter must either be an object or the name of an existing class");
+		RETURN_NULL();
+	}
+
+	h = zend_get_hash_value(property, property_len+1);
+	if (zend_hash_quick_find(&ce->properties_info, property, property_len+1, h, (void **) &property_info) == SUCCESS) {
+		if (property_info->flags & ZEND_ACC_SHADOW) {
 			RETURN_FALSE;
 		}
-		if (zend_lookup_class(Z_STRVAL_P(object), Z_STRLEN_P(object), &pce TSRMLS_CC) == SUCCESS) {
-			ce = *pce;
-		} else {
-			RETURN_FALSE; /* shouldn't happen */
-		}
-		RETURN_BOOL(EG(scope) == ce);
+		RETURN_TRUE;
+	}
 
-	case IS_OBJECT:
-		if (Z_OBJ_HANDLER_P(object, has_property) && Z_OBJ_HANDLER_P(object, has_property)(object, &property_z, 2 TSRMLS_CC)) {
-			RETURN_TRUE;
-		}
-		RETURN_FALSE;
+	ZVAL_STRINGL(&property_z, property, property_len, 0);
 
-	default:
-		zend_error(E_WARNING, "First parameter must either be an object or the name of an existing class");
-		RETURN_NULL();
+	if (Z_TYPE_P(object) ==  IS_OBJECT &&
+		Z_OBJ_HANDLER_P(object, has_property) && 
+		Z_OBJ_HANDLER_P(object, has_property)(object, &property_z, 2 TSRMLS_CC)) {
+		RETURN_TRUE;
 	}
+	RETURN_FALSE;
 }
 /* }}} */
 
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/011.phpt?r1=1.1.2.2.2.1&r2=1.1.2.2.2.2&diff_format=u
Index: ZendEngine2/tests/011.phpt
diff -u ZendEngine2/tests/011.phpt:1.1.2.2.2.1 ZendEngine2/tests/011.phpt:1.1.2.2.2.2
--- ZendEngine2/tests/011.phpt:1.1.2.2.2.1	Wed Jun 18 23:38:37 2008
+++ ZendEngine2/tests/011.phpt	Mon Aug 18 17:44:02 2008
@@ -59,16 +59,16 @@
 Warning: property_exists() expects exactly 2 parameters, 1 given in %s on line %d
 NULL
 bool(true)
-bool(false)
-bool(false)
+bool(true)
+bool(true)
 bool(false)
 bool(false)
 bool(false)
 bool(false)
 bool(false)
 bool(true)
-bool(false)
-bool(false)
+bool(true)
+bool(true)
 bool(false)
 bool(false)
 
@@ -84,6 +84,6 @@
 bool(true)
 bool(true)
 bool(true)
-bool(false)
+bool(true)
 bool(true)
 Done
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug42211.phpt?r1=1.1.2.1&r2=1.1.2.1.2.1&diff_format=u
Index: ZendEngine2/tests/bug42211.phpt
diff -u ZendEngine2/tests/bug42211.phpt:1.1.2.1 ZendEngine2/tests/bug42211.phpt:1.1.2.1.2.1
--- ZendEngine2/tests/bug42211.phpt:1.1.2.1	Wed Aug  8 13:32:46 2007
+++ ZendEngine2/tests/bug42211.phpt	Mon Aug 18 17:44:02 2008
@@ -22,9 +22,8 @@
 $b->foo();
 --EXPECT--
 bool(true)
-bool(false)
-bool(false)
 bool(true)
 bool(true)
-bool(false)
-
+bool(true)
+bool(true)
+bool(true)



-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.