Re: com php-src: Throw Error on dynamic call to instance method when called statically: Zend/zend_vm_def.h Zend/zend_vm_execute.h
| From: | Bob Weinand | Date: | Tue, 30 Jun 2015 11:34:02 +0000 |
| Subject: | Re: com php-src: Throw Error on dynamic call to instance method when called statically: Zend/zend_vm_def.h Zend/zend_vm_execute.h | ||
| References: | 1 2 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-87648@lists.php.net to get a copy of this message | ||
Note that this fix actually just sets a value before it is assigned at all. It's impossible to
have an impact, if not through luck because the variable was never set.
I just verified, your test script already wasn't working before. It's totally not related
to this commit.
But I can try fixing it.
Bob
> Am 30.06.2015 um 13:16 schrieb Dmitry Stogov <dmitry@zend.com>:
>
> Hi Bob,
>
> The "fix" breaks the ability to call methods from compatible context.
>
> <?php
> class A {
> function foo() {
> var_dump($this);
> }
> }
> class B extends A {
> function bar() {
> A::foo();
> (["A","foo"])(); // THIS DOES NOT WORK ANY MORE
> }
> }
> $b = new B();
> $b->bar();
> A::foo();
> (["A","foo"])();
> ?>
>
> Bob, I catch mistake in your every second commit !
> This can't work in this way, especially because some mistakes may be missed in final
> release stage.
> You often have good ideas, and in most cases you patches make sense, but you also makes
> mistakes too often.
>
> Nikita, do you review Bob's patches?
>
> Thanks. Dmitry.
>
>
> On Tue, Jun 30, 2015 at 8:07 AM, Bob Weinand <bwoebi@php.net
> <mailto:bwoebi@php.net>> wrote:
> Commit: ffd36e0fc8c91c415a6e10f4f06f39c2508bfe64
> Author: Aaron Piotrowski <aaron@trowski.com
> <mailto:aaron@trowski.com>> Mon, 29 Jun 2015
> 20:41:08 -0500
> Committer: Bob Weinand <bobwei9@hotmail.com
> <mailto:bobwei9@hotmail.com>> Tue, 30 Jun 2015
> 07:07:17 +0200
> Parents: dd2e6e866db17e4458a706b729288bfae857fa17
> Branches: master
>
> Link:
> http://git.php.net/?p=php-src.git;a=commitdiff;h=ffd36e0fc8c91c415a6e10f4f06f39c2508bfe64
> <http://git.php.net/?p=php-src.git;a=commitdiff;h=ffd36e0fc8c91c415a6e10f4f06f39c2508bfe64>
>
> Log:
> Throw Error on dynamic call to instance method when called statically
>
> Changed paths:
> M Zend/zend_vm_def.h
> M Zend/zend_vm_execute.h
>
>
> Diff:
> diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
> index a153d2a..7c7948e 100644
> --- a/Zend/zend_vm_def.h
> +++ b/Zend/zend_vm_def.h
> @@ -3237,6 +3237,7 @@ ZEND_VM_C_LABEL(try_function_name):
>
> lcname = zend_string_init(Z_STRVAL_P(function_name), cname_length, 0);
>
> + object = NULL;
> called_scope = zend_fetch_class_by_name(lcname, NULL,
> ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
> if (UNEXPECTED(called_scope == NULL)) {
> zend_string_release(lcname);
> diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
> index 64fa70d..ffe90f4 100644
> --- a/Zend/zend_vm_execute.h
> +++ b/Zend/zend_vm_execute.h
> @@ -1944,6 +1944,7 @@ try_function_name:
>
> lcname = zend_string_init(Z_STRVAL_P(function_name), cname_length, 0);
>
> + object = NULL;
> called_scope = zend_fetch_class_by_name(lcname, NULL,
> ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
> if (UNEXPECTED(called_scope == NULL)) {
> zend_string_release(lcname);
> @@ -2396,6 +2397,7 @@ try_function_name:
>
> lcname = zend_string_init(Z_STRVAL_P(function_name), cname_length, 0);
>
> + object = NULL;
> called_scope = zend_fetch_class_by_name(lcname, NULL,
> ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
> if (UNEXPECTED(called_scope == NULL)) {
> zend_string_release(lcname);
> @@ -2649,6 +2651,7 @@ try_function_name:
>
> lcname = zend_string_init(Z_STRVAL_P(function_name), cname_length, 0);
>
> + object = NULL;
> called_scope = zend_fetch_class_by_name(lcname, NULL,
> ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
> if (UNEXPECTED(called_scope == NULL)) {
> zend_string_release(lcname);
>
>
> --
> PHP CVS Mailing List (http://www.php.net/
> <http://www.php.net/>)
> To unsubscribe, visit: http://www.php.net/unsub.php
> <http://www.php.net/unsub.php>
>
>