Commit graph

9 commits

Author SHA1 Message Date
Ilija Tovilo
048fa7bacc
Fix get_object_vars() for non-hooked props in hooked prop iter
The zend_hash_update_ind() variant unwraps indirects, rather than creating them.
Don't use _zend_hash_append_ind() because the property might already exist.

Fixes GH-16725
Closes GH-16805
2024-11-18 16:20:19 +01:00
Ilija Tovilo
d76ef13757
Fix various hooked object iterator issues
Fixes GH-16185
Closes GH-16281
2024-10-08 13:35:33 +02:00
Arnaud Le Blanc
c9dfb77446
Deny resetting an object as lazy during property iteration
Supporting object reset while its properties are being iterated would increase
complexity for little benefit. Furthermore it may not be possible to ensure a
consistent behavior between ghosts and proxies (wrt to iteration position).

Iteration is detected by checking if the object's properties ht has iterators.
This requires refactoring the hooked get_iterator() implementation to ensure
that it creates a properties ht iterator immediately.

Closes GH-15960
2024-10-03 15:12:21 +02:00
Arnaud Le Blanc
4d7fcea5da
Fix handling of undef property during foreach by ref on hooked class 2024-10-03 15:12:21 +02:00
Arnaud Le Blanc
17d46bb3b2
Fix oss-fuzz #71382 (#15854)
The return value of zho_build_properties_ex() is passed to ZVAL_ARR(), which sets the IS_TYPE_REFCOUNTED flag. Returning &zend_emtpy_array will crash later when trying to dtor the zval.

I'm fixing this by returning zend_new_array(0) instead of &zend_empty_array.

An alternative was to make ZVAL_ARR() aware of immutable arrays, like ZVAL_STR() is with interned strings, but I found no other problematic cases.
2024-09-17 16:06:51 +02:00
Arnaud Le Blanc
58aa6fc830
Lazy objects
RFC: https://wiki.php.net/rfc/lazy-objects

Closes GH-15019
2024-08-30 17:30:03 +02:00
Ilija Tovilo
327588abf9
Replace OBJ_PROP_PTR_TO_NUM() with zend_get_property_info_for_slot()
I wasn't aware such a function already existed.
2024-08-20 18:44:42 +02:00
Ilija Tovilo
60f87f29bb
Fix various hooked object iterator issues (GH-15394)
Fixes GH-15187
2024-08-19 15:46:20 +02:00
Ilija Tovilo
780a8280d2
[RFC] Property hooks (#13455)
RFC: https://wiki.php.net/rfc/property-hooks

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2024-07-14 11:55:03 +02:00