Skip to content

Conversation

@alexandre-daubois
Copy link
Member

Use zend_update_property() instead of doing things "manually".

@alexandre-daubois alexandre-daubois linked an issue Nov 3, 2025 that may be closed by this pull request
@alexandre-daubois alexandre-daubois marked this pull request as ready for review November 3, 2025 09:02
Copy link
Member

@ndossche ndossche left a comment

Choose a reason for hiding this comment

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

On a phone , so can't check. But you're looking at the property info now, however dynamic properties don't have any. So that means that a dynamically created property $stream would've been overwritten before this patch but now no longer. So that is an unintended behaviour change.

@alexandre-daubois
Copy link
Member Author

Oh alright, I wasn't aware of this subtlety of dynamic properties. Let's refine that.

@bukka
Copy link
Member

bukka commented Nov 3, 2025

Hmm so that would require to someone create the dynamic property in filter first and it could then be used in subsequent calls for stream, right? If so, that sounds like a proper edge case... :)

@ndossche
Copy link
Member

ndossche commented Nov 3, 2025

The easiest way to test this is to create a onCreate method that sets a dynamic property on $this

@ndossche
Copy link
Member

ndossche commented Nov 4, 2025

This will work, except for a pre-existing bug:
When there is an unset or uninit typed property, but it is declared, its existence will be ignored.

It would also be great to try to avoid OBJPROP so that the property table isn't rebuilt, but that isn't critical.

@alexandre-daubois
Copy link
Member Author

alexandre-daubois commented Nov 4, 2025

I tried to implement what you have in mind in 04e0955

@alexandre-daubois alexandre-daubois force-pushed the user-stream-filter-props branch 2 times, most recently from 7208c60 to 04e0955 Compare November 4, 2025 08:33
Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

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

This looks good to me!

Maybe @bukka or @ndossche want to take another look.

Copy link
Member

@ndossche ndossche left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this. As I said in the issue I opened, it's a bit of an annoying issue (as you have felt).

@alexandre-daubois
Copy link
Member Author

Thanks @ndossche, I addressed your comments in the last commit

Copy link
Member

@ndossche ndossche left a comment

Choose a reason for hiding this comment

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

See last nit, once that's resolved I think this can be approved.

@ndossche
Copy link
Member

Thanks for tackling this annoying issue

Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

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

It looks correct to me. We should probably introduce some nicer api for that fake_scope as it has not been used outside zend and reflection. It should not be directly accessed filters code IMHO but new API is more master material...

Copy link
Member

@ndossche ndossche left a comment

Choose a reason for hiding this comment

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

Thanks. Go ahead.

@alexandre-daubois alexandre-daubois merged commit 77f2d12 into php:PHP-8.3 Dec 4, 2025
8 of 9 checks passed
alexandre-daubois added a commit that referenced this pull request Dec 4, 2025
* PHP-8.3:
  Fix GH-20370: forbid user stream filters to violate typed property constraints (#20373)
alexandre-daubois added a commit that referenced this pull request Dec 4, 2025
* PHP-8.4:
  Fix GH-20370: forbid user stream filters to violate typed property constraints (#20373)
alexandre-daubois added a commit that referenced this pull request Dec 4, 2025
* PHP-8.5:
  Fix GH-20370: forbid user stream filters to violate typed property constraints (#20373)
@alexandre-daubois
Copy link
Member Author

Thanks for your reviews!

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.

User filters allow breaking typed properties

5 participants