com php-src: Fixed bug #77877 (call_user_func() pas ses $this to satatic methods).: NEWS Zend/t ests/bug77877.phpt Zend/zend_API.c

From: Date: Thu, 11 Apr 2019 11:24:04 +0000
Subject: com php-src: Fixed bug #77877 (call_user_func() pas ses $this to satatic methods).: NEWS Zend/t ests/bug77877.phpt Zend/zend_API.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-105650@lists.php.net to get a copy of this message
Commit: a1b7ccdfc69a1ad9938039f687ad7059ed1bd506 Author: Dmitry Stogov <dmitry@zend.com> Thu, 11 Apr 2019 14:24:04 +0300 Parents: cd8312a77e5f5fee62949ecb22664e8b24013c01 Branches: PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a1b7ccdfc69a1ad9938039f687ad7059ed1bd506 Log: Fixed bug #77877 (call_user_func() passes $this to satatic methods). Bugs: https://bugs.php.net/77877 Changed paths: M NEWS A Zend/tests/bug77877.phpt M Zend/zend_API.c Diff: diff --git a/NEWS b/NEWS index 178b551..faa1c16 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ PHP NEWS - Core: . Fixed bug #77345 (Stack Overflow caused by circular reference in garbage collection). (Alexandru Patranescu, Nikita, Dmitry) + . Fixed bug #77877 (call_user_func() passes $this to satatic methods). + (Dmitry) . Implemented request #76148 (Add array_key_exists() to the list of specially compiled functions). (Majkl578) . Fixed bug #76430 (__METHOD__ inconsistent outside of method). diff --git a/Zend/tests/bug77877.phpt b/Zend/tests/bug77877.phpt new file mode 100644 index 0000000...9e0181e --- /dev/null +++ b/Zend/tests/bug77877.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #77877 call_user_func() passes $this to satatic methods +--FILE-- +<?php +class Foo { + static public function bar() { + var_dump($this); + } +} +try { + array_map([new Foo, 'bar'],[1]); +} catch (Throwable $e) { + echo $e->getMessage() . "\n"; +} +try { + call_user_func([new Foo, 'bar']); +} catch (Throwable $e) { + echo $e->getMessage() . "\n"; +} +?> +--EXPECT-- +Using $this when not in object context +Using $this when not in object context diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 881ee27..20b5fbb 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3170,6 +3170,10 @@ get_function_via_handler: if (fcc->object) { fcc->called_scope = fcc->object->ce; + if (fcc->function_handler + && fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC) { + fcc->object = NULL; + } } return retval; }

« previous php.cvs (#105650) next »