Skip to content

Conversation

@cmb69
Copy link
Member

@cmb69 cmb69 commented Apr 21, 2020

When retrieving the static class properties via reflection, we have to
cater to possible modifications.

When retrieving the static class properties via reflection, we have to
cater to possible modifications.
@cmb69 cmb69 added the Bug label Apr 21, 2020
As suggested by Nikita.
@cmb69
Copy link
Member Author

cmb69 commented Apr 21, 2020

Thanks @nikic! I'll have a closer look at this ASAP.

@nikic
Copy link
Member

nikic commented May 19, 2020

Ping

@cmb69
Copy link
Member Author

cmb69 commented May 19, 2020

Sorry for the delay.

@cmb69
Copy link
Member Author

cmb69 commented Jun 23, 2020

Pong :)

@nikic
Copy link
Member

nikic commented Jun 23, 2020

@cmb69

<?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:

array(2) {
  ["b"]=>
  string(5) "B old"
  ["a"]=>
  string(5) "A old"
}

This is necessary for inherited properties, and allows us to drop the
check later.

We also remove the unnecessary `IS_CONSTANT_AST` handling.

/* copy: enforce read only access */
ZVAL_DEREF(prop);
ZVAL_COPY_OR_DUP(&prop_copy, prop);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine! :)

Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG apart from the comment.

@cmb69
Copy link
Member Author

cmb69 commented Jun 23, 2020

Thanks! Applied as a895bb6.

@cmb69 cmb69 closed this Jun 23, 2020
@cmb69 cmb69 deleted the cmb/79487 branch June 23, 2020 16:54
@cmb69
Copy link
Member Author

cmb69 commented Jun 24, 2020

FTR: I had to revert a895bb6 due to segfaults in mysqli tests. Amended PR now applied as f3cccfd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants