Fix GH-21478: Forward read_property to real instance for initialized lazy proxies#21480
Open
iliaal wants to merge 1 commit intophp:masterfrom
Open
Fix GH-21478: Forward read_property to real instance for initialized lazy proxies#21480iliaal wants to merge 1 commit intophp:masterfrom
iliaal wants to merge 1 commit intophp:masterfrom
Conversation
…ed lazy proxies When an initialized lazy proxy has __get/__isset, zend_std_read_property() was calling the magic method on the proxy itself before forwarding to the real instance at uninit_error. This caused double invocations: __get fired on both the real instance and the proxy. For pure reads (BP_VAR_R, BP_VAR_IS), forward directly to the real instance before attempting magic methods on the proxy. Write contexts (BP_VAR_W/RW) are excluded because read_property with those types is used as a fallback from get_property_ptr_ptr for reference operations involving __get. Closes phpGH-21478
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.
Summary
zend_std_read_property()was calling__get/__isseton an initialized lazy proxy before forwarding to the real instance. This produced double magic method invocations when the real instance's__getaccessed the proxy -- the proxy's own guard was clear, so__getfired on the proxy too.For pure reads (
BP_VAR_R,BP_VAR_IS), forward directly to the real instance before attempting magic methods on the proxy. Write contexts (BP_VAR_W/RW) are excluded sinceread_propertywith those types is a fallback fromget_property_ptr_ptrfor reference operations.Also updates
gh18038-004andgh18038-007test expectations to match -- these tests previously asserted the double-call behavior that GH-21478 reports as a bug.Fixes #21478