[php-src] PR #20720: Fix GH-20503: Assertion failure with ext/date DateInterval property hash construction
| From: | heathdutton | Date: | Tue, 16 Dec 2025 23:40:27 +0000 |
| Subject: | [php-src] PR #20720: Fix GH-20503: Assertion failure with ext/date DateInterval property hash construction | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-34301@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20720
Author: heathdutton
When a DateInterval object has a circular reference (e.g.,
$obj->prop = $obj),
calling json_encode() triggers an assertion failure in debug builds. This happens
because the get_properties handler tries to modify the properties HashTable in place,
but circular references cause the HashTable to have a refcount > 1, which violates the assertion
in zend_hash_str_update().
This adds a get_properties_for handler for DateInterval that duplicates the properties
array before adding the internal interval properties. This matches the existing pattern used by
DateTime and DateTimeZone, which already have both handlers for the same reason.
The original get_properties handler is preserved for backward compatibility with
get_object_vars().
Fixes GH-20503