[php-src] PHP-8.5: Fixed __debugInfo() usage on PHP 8.5 and later for DatePeriod (#22677)

Derick Rethans via GitHub <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Derick Rethans (derickr)
Committer: GitHub (web-flow)
Pusher: derickr
Date: 2026-07-10T16:52:26+01:00

Commit: https://github.com/php/php-src/commit/032b2d392de231c0cdbbc886be5f00fa59dc98c1
Raw diff: https://github.com/php/php-src/commit/032b2d392de231c0cdbbc886be5f00fa59dc98c1.diff

Fixed __debugInfo() usage on PHP 8.5 and later for DatePeriod (#22677)

Changed paths:
  M  ext/date/php_date.c


Diff:

diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index bcf4bcdded06..ad4b4a51101e 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -6076,6 +6076,17 @@ static zval *date_period_get_property_ptr_ptr(zend_object *object, zend_string *
 
 static HashTable *date_period_get_properties_for(zend_object *object, zend_prop_purpose purpose)
 {
+	if (purpose == ZEND_PROP_PURPOSE_DEBUG) {
+		if (object->ce->__debugInfo) {
+			int is_temp = 0;
+			HashTable *ht = zend_std_get_debug_info(object, &is_temp);
+			if (ht && !is_temp) {
+				GC_TRY_ADDREF(ht);
+			}
+			return ht;
+		}
+	}
+
 	php_period_obj *period_obj = php_period_obj_from_obj(object);
 	HashTable *props = zend_array_dup(zend_std_get_properties(object));
 	if (!period_obj->initialized) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.