cvs: ZendEngine2 / zend_object_handlers.c /tests bug42937.phpt

From: Date: Mon, 12 Nov 2007 09:12:20 +0000
Subject: cvs: ZendEngine2 / zend_object_handlers.c /tests bug42937.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-6152@lists.php.net to get a copy of this message
dmitry Mon Nov 12 09:12:20 2007 UTC Modified files: /ZendEngine2 zend_object_handlers.c /ZendEngine2/tests bug42937.phpt Log: Fixed bug #42937 (__call() method not invoked when methods are called on parent from child class). http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_object_handlers.c?r1=1.190&r2=1.191&diff_format=u Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.190 ZendEngine2/zend_object_handlers.c:1.191 --- ZendEngine2/zend_object_handlers.c:1.190 Sun Oct 7 05:15:03 2007 +++ ZendEngine2/zend_object_handlers.c Mon Nov 12 09:12:20 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.c,v 1.190 2007/10/07 05:15:03 davidw Exp $ */ +/* $Id: zend_object_handlers.c,v 1.191 2007/11/12 09:12:20 dmitry Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -908,7 +908,29 @@ zend_function *fbc; if (zend_u_hash_find(&ce->function_table, type, function_name_strval, function_name_strlen + 1, (void **) &fbc)==FAILURE) { - if (ce->__callstatic) { + if (ce->__call && + EG(This) && + Z_OBJ_HT_P(EG(This))->get_class_entry && + instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { + zend_internal_function *call_user_call = emalloc(sizeof(zend_internal_function)); + + call_user_call->type = ZEND_INTERNAL_FUNCTION; + call_user_call->module = ce->module; + call_user_call->handler = zend_std_call_user_call; + call_user_call->arg_info = NULL; + call_user_call->num_args = 0; + call_user_call->scope = ce; + call_user_call->fn_flags = 0; + if (UG(unicode)) { + call_user_call->function_name.u = eustrndup(function_name_strval.u, function_name_strlen); + } else { + call_user_call->function_name.s = estrndup(function_name_strval.s, function_name_strlen); + } + call_user_call->pass_rest_by_reference = 0; + call_user_call->return_reference = ZEND_RETURN_VALUE; + + return (union _zend_function *)call_user_call; + } else if (ce->__callstatic) { zend_internal_function *callstatic_user_call = emalloc(sizeof(zend_internal_function)); callstatic_user_call->type = ZEND_INTERNAL_FUNCTION; callstatic_user_call->module = ce->module; http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug42937.phpt?r1=1.1&r2=1.2&diff_format=u Index: ZendEngine2/tests/bug42937.phpt diff -u /dev/null ZendEngine2/tests/bug42937.phpt:1.2 --- /dev/null Mon Nov 12 09:12:20 2007 +++ ZendEngine2/tests/bug42937.phpt Mon Nov 12 09:12:20 2007 @@ -0,0 +1,42 @@ +--TEST-- +Bug #42937 (__call() method not invoked when methods are called on parent from child class) +--FILE-- +<?php +class A { + function __call($strMethod, $arrArgs) { + echo "$strMethod\n"; + } +} + +class C { + function __call($strMethod, $arrArgs) { + echo "$strMethod\n"; + } +} + +class B extends A { + function test() { + self::test1(); + parent::test2(); + static::test3(); + A::test4(); + B::test5(); + C::test6(); + } +} + +$a = new A(); +$a->test(); + +$b = new B(); +$b->test(); +?> +--EXPECTF-- +test +test1 +test2 +test3 +test4 +test5 + +Fatal error: Call to undefined method C::test6() in %sbug42937.php on line 21

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