Fix #79487: ::getStaticProperties() ignores property modifications#5429
Closed
cmb69 wants to merge 5 commits intophp:PHP-7.4from
Closed
Fix #79487: ::getStaticProperties() ignores property modifications#5429cmb69 wants to merge 5 commits intophp:PHP-7.4from
cmb69 wants to merge 5 commits intophp:PHP-7.4from
Conversation
When retrieving the static class properties via reflection, we have to cater to possible modifications.
nikic
reviewed
Apr 21, 2020
As suggested by Nikita.
nikic
reviewed
Apr 21, 2020
nikic
reviewed
Apr 21, 2020
nikic
reviewed
Apr 21, 2020
Member
Author
|
Thanks @nikic! I'll have a closer look at this ASAP. |
Member
|
Ping |
Member
Author
|
Sorry for the delay. |
Member
Author
|
Pong :) |
Member
<?php
class A {
public static $a = 'A old';
}
class B extends A {
public static $b = 'B old';
}
$rc = new ReflectionClass(B::class);
A::$a = 'A new';
var_dump($rc->getStaticProperties());Incorrectly prints under opcache: |
This is necessary for inherited properties, and allows us to drop the check later. We also remove the unnecessary `IS_CONSTANT_AST` handling.
nikic
reviewed
Jun 23, 2020
|
|
||
| /* copy: enforce read only access */ | ||
| ZVAL_DEREF(prop); | ||
| ZVAL_COPY_OR_DUP(&prop_copy, prop); |
Member
There was a problem hiding this comment.
The CE_STATIC_MEMBERS is already per-request, so it's not necessary to COPY_OR_DUP. Just doing a Z_TRY_ADDREF_P(prop) is sufficient here.
Member
Author
|
Thanks! Applied as a895bb6. |
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When retrieving the static class properties via reflection, we have to
cater to possible modifications.