[php-src] PR #20181: Fix assertion failure in ReflectionProperty::skipLazyInitialization after failed LazyProxy initialization
| From: | arnaud-lb | Date: | Wed, 15 Oct 2025 14:16:27 +0000 |
| Subject: | [php-src] PR #20181: Fix assertion failure in ReflectionProperty::skipLazyInitialization after failed LazyProxy initialization | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-33656@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20181
Author: arnaud-lb
Fixes GH-20174
We don't expect the lazy proxy to be modified during initialization, but that's allowed.
The modification may set a property, still marked LAZY, without removing the LAZY flag. This causes
the assertion failure.
Both the [RFC](https://wiki.php.net/rfc/lazy-objects#common_behavior) and the
[documentation](https://www.php.net/manual/en/language.oop5.lazy-objects.php#language.oop5.lazy-objects.initialization-sequence)
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).
Here I fix the issue by implementing the missing behavior.