cvs: ZendEngine2(PHP_5_3) / zend_API.c /tests bug46246.phpt
[email protected] ("Dmitry Stogov")
| Newsgroups | php.zend-engine.cvs |
|---|---|
| Message-ID | <cvsdmitry1223651976@cvsserver> |
dmitry Fri Oct 10 15:19:36 2008 UTC
Added files: (Branch: PHP_5_3)
/ZendEngine2/tests bug46246.phpt
Modified files:
/ZendEngine2 zend_API.c
Log:
Fixed bug #46246 (difference between call_user_func(array($this, $method)) and $this->$method())
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.296.2.27.2.34.2.53&r2=1.296.2.27.2.34.2.54&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.296.2.27.2.34.2.53 ZendEngine2/zend_API.c:1.296.2.27.2.34.2.54
--- ZendEngine2/zend_API.c:1.296.2.27.2.34.2.53 Fri Aug 22 14:51:30 2008
+++ ZendEngine2/zend_API.c Fri Oct 10 15:19:35 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.296.2.27.2.34.2.53 2008/08/22 14:51:30 tony2001 Exp $ */
+/* $Id: zend_API.c,v 1.296.2.27.2.34.2.54 2008/10/10 15:19:35 dmitry Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -2465,10 +2465,23 @@
lmname = zend_str_tolower_dup(mname, mlen);
if (zend_hash_find(ftable, lmname, mlen+1, (void**)&fcc->function_handler) == SUCCESS) {
retval = 1;
- } else if (fcc->object_pp && Z_OBJ_HT_PP(fcc->object_pp)->get_method) {
- fcc->function_handler = Z_OBJ_HT_PP(fcc->object_pp)->get_method(fcc->object_pp, mname, mlen TSRMLS_CC);
- retval = fcc->function_handler ? 1 : 0;
- call_via_handler = 1;
+ if ((fcc->function_handler->op_array.fn_flags & ZEND_ACC_CHANGED) &&
+ EG(scope) &&
+ instanceof_function(fcc->function_handler->common.scope, EG(scope) TSRMLS_CC)) {
+ zend_function *priv_fbc;
+
+ if (zend_hash_find(&EG(scope)->function_table, lmname, mlen+1, (void **) &priv_fbc)==SUCCESS
+ && priv_fbc->common.fn_flags & ZEND_ACC_PRIVATE
+ && priv_fbc->common.scope == EG(scope)) {
+ fcc->function_handler = priv_fbc;
+ }
+ }
+ } else if (fcc->object_pp) {
+ if (Z_OBJ_HT_PP(fcc->object_pp)->get_method) {
+ fcc->function_handler = Z_OBJ_HT_PP(fcc->object_pp)->get_method(fcc->object_pp, mname, mlen TSRMLS_CC);
+ retval = fcc->function_handler ? 1 : 0;
+ call_via_handler = 1;
+ }
} else if (fcc->calling_scope) {
if (fcc->calling_scope->get_static_method) {
fcc->function_handler = fcc->calling_scope->get_static_method(fcc->calling_scope, mname, mlen TSRMLS_CC);
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug46246.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug46246.phpt
+++ ZendEngine2/tests/bug46246.phpt
--TEST--
Bug #46246 (difference between call_user_func(array($this, $method)) and $this->$method())
--FILE--
<?php
class A
{
private function Test()
{
echo 'Hello from '.get_class($this)."\n";
}
public function call($method, $args = array())
{
$this->Test();
$this->$method();
call_user_func(array($this, $method));
}
}
class B extends A
{
protected function Test()
{
echo 'Overridden hello from '.get_class($this)."\n";
}
}
$a = new A;
$b = new B;
$a->call('Test');
$b->call('Test');
?>
--EXPECT--
Hello from A
Hello from A
Hello from A
Hello from B
Hello from B
Hello from B