Skip to content

Conversation

@pull
Copy link

@pull pull bot commented Feb 26, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

iluuu1994 and others added 9 commits February 26, 2025 20:49
* PHP-8.4:
  Fix property hook backing value access in multi-level inheritance
* PHP-8.4:
  Fix accidentally inherited default value in overridden virtual properties
The following code poses a problem in the JIT:

```php
class A {
    public $prop = 1;
}

class B extends A {
    public $prop = 1 {
        get => parent::$prop::get() * 2;
    }
}

function test(A $a) {
    var_dump($a->prop);
}

test(new B);
```

The JIT would assume A::$prop in test() could be accessed directly
through OBJ_PROP_NUM(). However, since child classes can add new hooks
to existing properties, this assumption no longer holds.

To avoid introducing more JIT checks, a hooked property that overrides a
unhooked property now results in a separate zval slot that is used
instead of the parent slot. This causes the JIT to pick the slow path
due to an IS_UNDEF value in the parent slot.

zend_class_entry.properties_info_table poses a problem in that
zend_get_property_info_for_slot() and friends will be called using the
child slot, which does not store its property info, since the parent
slot already does. In this case, zend_get_property_info_for_slot() now
provides a fallback that will iterate all property infos to find the
correct one.

This also uncovered a bug (see Zend/tests/property_hooks/dump.phpt)
where the default value of a parent property would accidentally be
inherited by the child property.

Fixes GH-17376
Closes GH-17870
* PHP-8.4:
  Fix circumvented added hooks in JIT
* PHP-8.4:
  Fix varying pgsql error message
Co-authored-by: Michael Voříšek <[email protected]>

Closes GH-17874
@pull pull bot added the ⤵️ pull label Feb 26, 2025
@pull pull bot merged commit 2b2a70d into wudi:master Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants