cvs: ZendEngine2(PHP_5_3) / zend_object_handlers.c /tests bug48215.phpt

[email protected] ("Scott MacVicar") Thu, 18 Jun 2009 13:46:16 -0000
Newsgroups php.zend-engine.cvs
Message-ID <cvsscottmac1245332776@cvsserver>
scottmac		Thu Jun 18 13:46:16 2009 UTC

  Added files:                 (Branch: PHP_5_3)
    /ZendEngine2/tests	bug48215.phpt 

  Modified files:              
    /ZendEngine2	zend_object_handlers.c 
  Log:
  Fix bug #48215 - Calling a method with the same name as the parent class calls the constructor instead.
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_object_handlers.c?r1=1.135.2.6.2.22.2.29&r2=1.135.2.6.2.22.2.30&diff_format=u
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.135.2.6.2.22.2.29 ZendEngine2/zend_object_handlers.c:1.135.2.6.2.22.2.30
--- ZendEngine2/zend_object_handlers.c:1.135.2.6.2.22.2.29	Fri Jun 12 21:36:53 2009
+++ ZendEngine2/zend_object_handlers.c	Thu Jun 18 13:46:16 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_object_handlers.c,v 1.135.2.6.2.22.2.29 2009/06/12 21:36:53 felipe Exp $ */
+/* $Id: zend_object_handlers.c,v 1.135.2.6.2.22.2.30 2009/06/18 13:46:16 scottmac Exp $ */
 
 #include "zend.h"
 #include "zend_globals.h"
@@ -28,6 +28,7 @@
 #include "zend_object_handlers.h"
 #include "zend_interfaces.h"
 #include "zend_closures.h"
+#include "zend_compile.h"
 
 #define DEBUG_OBJECT_HANDLERS 0
 
@@ -941,7 +942,8 @@
 
 	if (function_name_strlen == ce->name_length && ce->constructor) {
 		lc_class_name = zend_str_tolower_dup(ce->name, ce->name_length);
-		if (!memcmp(lc_class_name, function_name_strval, function_name_strlen)) {
+		/* Only change the method to the constructor if a __construct() method doesn't exist */
+		if (!memcmp(lc_class_name, function_name_strval, function_name_strlen) && memcmp(ce->constructor->common.function_name, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) {
 			fbc = ce->constructor;
 		}
 		efree(lc_class_name);

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug48215.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug48215.phpt
+++ ZendEngine2/tests/bug48215.phpt