[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6

From: Date: Thu, 15 Oct 2026 17:32:03 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142326@lists.php.net to get a copy of this message
Author: Arnaud Le Blanc (arnaud-lb) Date: 2026-10-15T19:31:12+02:00 Commit: https://github.com/php/php-src/commit/d4265ca89ce6ad961475b4829b18271af4f832a4 Raw diff: https://github.com/php/php-src/commit/d4265ca89ce6ad961475b4829b18271af4f832a4.diff Merge branch 'PHP-8.5' into PHP-8.6 * PHP-8.5: [ci skip] NEWS Fix GH-20503: Assertion failure with ext/date DateInterval property hash (#20720) Changed paths: A ext/date/tests/bug-gh20503.phpt M NEWS M ext/date/php_date.c Diff: diff --git a/NEWS b/NEWS index c47a2db8b554..d746ac9130cb 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,10 @@ PHP NEWS . Fixed array_map() optimization not resolving the class name of a static first-class callable. (Claudio Dekker) +- Date: + . Fixed bug GH-20503 (Assertion failure with ext/date DateInterval property + hash construction). (heathdutton) + - Fileinfo: . Fixed bug GH-24289 (finfo::file() reports the wrong argument number for an invalid $filename). (Lazizbek Ergashev) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 1795d41b27ce..2118aea16389 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2234,6 +2234,12 @@ static HashTable *date_object_get_properties_interval(zend_object *object) /* {{ return props; } + /* The table may still be held elsewhere (e.g. json_encode() walking a cycle), so separate it before writing */ + if (UNEXPECTED(GC_REFCOUNT(props) > 1)) { + GC_TRY_DELREF(props); + props = object->properties = zend_array_dup(props); + } + date_interval_object_to_hash(intervalobj, props); return props; diff --git a/ext/date/tests/bug-gh20503.phpt b/ext/date/tests/bug-gh20503.phpt new file mode 100644 index 000000000000..468afb3d124b --- /dev/null +++ b/ext/date/tests/bug-gh20503.phpt @@ -0,0 +1,33 @@ +--TEST-- +GH-20503 (Assertion failure with ext/date DateInterval property hash construction) +--SKIPIF-- +<?php +if (ini_get('zend.max_allowed_stack_size') === false) { + die('skip No stack limit support'); +} +if (getenv('SKIP_ASAN')) { + die('skip ASAN needs different stack limit setting due to more stack space usage'); +} +?> +--INI-- +zend.max_allowed_stack_size=512K +--FILE-- +<?php +$obj = new DateInterval('P1W'); +$obj->prop3 = $obj; +var_dump(json_encode($obj)); +var_dump(json_last_error_msg()); + +$obj2 = new DateInterval('P1D'); +$obj2->prop = [$obj2]; +var_dump(json_encode($obj2)); +var_dump(json_last_error_msg()); +?> +--EXPECTF-- +Deprecated: Creation of dynamic property DateInterval::$prop3 is deprecated in %s on line %d +bool(false) +string(28) "Maximum stack depth exceeded" + +Deprecated: Creation of dynamic property DateInterval::$prop is deprecated in %s on line %d +bool(false) +string(18) "Recursion detected"

« previous php.cvs (#142326) next »