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

From: Date: Mon, 17 Mar 2008 14:54:42 +0000
Subject: cvs: ZendEngine2(PHP_5_3) / zend_compile.c zend_object_handlers.c /tests bug39127.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-6532@lists.php.net to get a copy of this message
tony2001 Mon Mar 17 14:54:42 2008 UTC Added files: (Branch: PHP_5_3) /ZendEngine2/tests bug39127.phpt Modified files: /ZendEngine2 zend_compile.c zend_object_handlers.c Log: MFH: fix #39127 (Old-style constructor fallbacks produce strange results) http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.647.2.27.2.41.2.50&r2=1.647.2.27.2.41.2.51&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.50 ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.51 --- ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.50 Sun Mar 16 21:05:33 2008 +++ ZendEngine2/zend_compile.c Mon Mar 17 14:54:42 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.50 2008/03/16 21:05:33 helly Exp $ */ +/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.51 2008/03/17 14:54:42 tony2001 Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -2197,10 +2197,11 @@ lc_class_name = zend_str_tolower_dup(ce->name, ce->name_length); if (!zend_hash_exists(&ce->function_table, lc_class_name, ce->name_length+1)) { lc_parent_class_name = zend_str_tolower_dup(ce->parent->name, ce->parent->name_length); - if (zend_hash_find(&ce->parent->function_table, lc_parent_class_name, ce->parent->name_length+1, (void **)&function)==SUCCESS) { + if (!zend_hash_exists(&ce->function_table, lc_parent_class_name, ce->parent->name_length+1) && + zend_hash_find(&ce->parent->function_table, lc_parent_class_name, ce->parent->name_length+1, (void **)&function)==SUCCESS) { if (function->common.fn_flags & ZEND_ACC_CTOR) { /* inherit parent's constructor */ - zend_hash_update(&ce->function_table, lc_class_name, ce->name_length+1, function, sizeof(zend_function), NULL); + zend_hash_update(&ce->function_table, lc_parent_class_name, ce->parent->name_length+1, function, sizeof(zend_function), NULL); function_add_ref(function); } } http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_object_handlers.c?r1=1.135.2.6.2.22.2.12&r2=1.135.2.6.2.22.2.13&diff_format=u Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.135.2.6.2.22.2.12 ZendEngine2/zend_object_handlers.c:1.135.2.6.2.22.2.13 --- ZendEngine2/zend_object_handlers.c:1.135.2.6.2.22.2.12 Thu Feb 21 13:55:45 2008 +++ ZendEngine2/zend_object_handlers.c Mon Mar 17 14:54:42 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.c,v 1.135.2.6.2.22.2.12 2008/02/21 13:55:45 dmitry Exp $ */ +/* $Id: zend_object_handlers.c,v 1.135.2.6.2.22.2.13 2008/03/17 14:54:42 tony2001 Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -892,9 +892,17 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC) /* {{{ */ { - zend_function *fbc; + zend_function *fbc = NULL; + char *lc_class_name; - if (zend_hash_find(&ce->function_table, function_name_strval, function_name_strlen + 1, (void **) &fbc)==FAILURE) { + 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)) { + fbc = ce->constructor; + } + efree(lc_class_name); + } + if (!fbc && zend_hash_find(&ce->function_table, function_name_strval, function_name_strlen+1, (void **) &fbc)==FAILURE) { if (ce->__call && EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug39127.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/bug39127.phpt +++ ZendEngine2/tests/bug39127.phpt --TEST-- Bug #39127 (Old-style constructor fallbacks produce strange results) --FILE-- <?php class a { function a() { var_dump("a::a() called"); } } class b extends a {} $b = new b; var_dump(is_callable(array($b,"a"))); var_dump(is_callable(array($b,"b"))); var_dump(is_callable(array($b,"__construct"))); echo "Done\n"; ?> --EXPECTF-- %s(13) "a::a() called" bool(true) bool(false) bool(false) Done

« previous php.zend-engine.cvs (#6532) next »