[php-src] PR #25110: Fix GH-25108: Skip uninitialized hooked properties in json_encode()
| From: | JoaoMarcos44 | Date: | Sat, 31 Oct 2026 18:47:20 +0000 |
| Subject: | [php-src] PR #25110: Fix GH-25108: Skip uninitialized hooked properties in json_encode() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40156@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25110
Author: JoaoMarcos44
Fixes #25108.
> AI-assisted contribution. The patch, regression test, and explanation were prepared with AI
> assistance and checked with local builds and tests.
## Summary
> Omit an uninitialized backed property when reading it through a setter hook during JSON
> encoding. Previously, adding a setter hook changed an omitted field into an explicit null.
> The encoder skips the uninitialized sentinel before emitting a property name. Explicit null
> values and getters returning null remain included. The PHPT also checks initialized values, virtual
> set-only properties, ordering, and pretty printing. A NEWS entry records the fix.
## Validation
> Target:
PHP-8.4, the lowest actively supported affected branch.
> Built with --enable-debug --enable-zts.
> - The new regression fails before the fix and passes afterward.
> - make -j1 passes.
> - make -j1 test TESTS="ext/json/tests
> Zend/tests/property_hooks" passes with 291 passed and 5 skipped. No failures or
> warnings. The skips concern unavailable zend_test support and locales. The test runner uses one
> worker.
> - The full PHP suite and Windows builds were not run.
<details>
<summary>Illustrated explanation</summary>
> AI-generated conceptual illustration. The issue contains the executable reproduction.

[Explanation and
prompt](https://github.com/JoaoMarcos44/php-src/blob/9e60fedb55c1c3bdfaeb339f1beeae2895526596/assets/json/infographic_report.md)
</details>