1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Revert lazy proxy state after failed initialization

We don't expect the lazy proxy to be modified during initialization, but
this is allowed. The modification may set a property, still marked LAZY,
without removing the LAZY flag. This causes an assertion failure in GH-20174.

Both the RFC and the documentation specify that after an initialization
failure, the state of the object is reset to its pre-initialization state:

    If the initializer throws an exception, the object state is reverted to
    its pre-initialization state and the object is marked as lazy again. In
    other words, all effects on the object itself are reverted. Other side
    effects, such as effects on other objects, are not reverted. This prevents
    exposing a partially initialized instance in case of failure.

This behavior would have prevented this issue, but it was not implemented
for lazy proxies (only for ghosts).

Fix by implementing the missing behavior.

Fixes GH-20174
Closes GH-20181
This commit is contained in:
Arnaud Le Blanc
2025-10-15 16:08:43 +02:00
parent 39f5ed943d
commit 4a1cca7ddc
8 changed files with 93 additions and 42 deletions

3
NEWS
View File

@@ -13,6 +13,9 @@ PHP NEWS
. Fixed GH-20564 (Don't call autoloaders with pending exception). (ilutov)
. Fix deprecation now showing when accessing null key of an array with JIT.
(alexandre-daubois)
. Fixed bug GH-20174 (Assertion failure in
ReflectionProperty::skipLazyInitialization after failed LazyProxy
initialization). (Arnaud)
- Date:
. Update timelib to 2022.16. (Derick)