@@ -153,12 +153,13 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */
153
153
php_printf ("%senum(%s::%s)\n" , COMMON , ZSTR_VAL (ce -> name ), Z_STRVAL_P (case_name_zval ));
154
154
return ;
155
155
}
156
-
157
- if (Z_IS_RECURSIVE_P (struc )) {
156
+ zend_object * zobj = Z_OBJ_P (struc );
157
+ uint32_t * guard = zend_get_recursion_guard (zobj );
158
+ if (ZEND_GUARD_OR_GC_IS_RECURSIVE (guard , DEBUG , zobj )) {
158
159
PUTS ("*RECURSION*\n" );
159
160
return ;
160
161
}
161
- Z_PROTECT_RECURSION_P ( struc );
162
+ ZEND_GUARD_OR_GC_PROTECT_RECURSION ( guard , DEBUG , zobj );
162
163
163
164
myht = zend_get_properties_for (struc , ZEND_PROP_PURPOSE_DEBUG );
164
165
class_name = Z_OBJ_HANDLER_P (struc , get_class_name )(Z_OBJ_P (struc ));
@@ -190,7 +191,7 @@ PHPAPI void php_var_dump(zval *struc, int level) /* {{{ */
190
191
php_printf ("%*c" , level - 1 , ' ' );
191
192
}
192
193
PUTS ("}\n" );
193
- Z_UNPROTECT_RECURSION_P ( struc );
194
+ ZEND_GUARD_OR_GC_UNPROTECT_RECURSION ( guard , DEBUG , zobj );
194
195
break ;
195
196
}
196
197
case IS_RESOURCE : {
@@ -342,16 +343,18 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level) /* {{{ */
342
343
}
343
344
PUTS ("}\n" );
344
345
break ;
345
- case IS_OBJECT :
346
+ case IS_OBJECT : {
346
347
/* Check if this is already recursing on the object before calling zend_get_properties_for,
347
348
* to allow infinite recursion detection to work even if classes return temporary arrays,
348
349
* and to avoid the need to update the properties table in place to reflect the state
349
350
* if the result won't be used. (https://github.com/php/php-src/issues/8044) */
350
- if (Z_IS_RECURSIVE_P (struc )) {
351
+ zend_object * zobj = Z_OBJ_P (struc );
352
+ uint32_t * guard = zend_get_recursion_guard (zobj );
353
+ if (ZEND_GUARD_OR_GC_IS_RECURSIVE (guard , DEBUG , zobj )) {
351
354
PUTS ("*RECURSION*\n" );
352
355
return ;
353
356
}
354
- Z_PROTECT_RECURSION_P ( struc );
357
+ ZEND_GUARD_OR_GC_PROTECT_RECURSION ( guard , DEBUG , zobj );
355
358
356
359
myht = zend_get_properties_for (struc , ZEND_PROP_PURPOSE_DEBUG );
357
360
class_name = Z_OBJ_HANDLER_P (struc , get_class_name )(Z_OBJ_P (struc ));
@@ -378,8 +381,9 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level) /* {{{ */
378
381
php_printf ("%*c" , level - 1 , ' ' );
379
382
}
380
383
PUTS ("}\n" );
381
- Z_UNPROTECT_RECURSION_P ( struc );
384
+ ZEND_GUARD_OR_GC_UNPROTECT_RECURSION ( guard , DEBUG , zobj );
382
385
break ;
386
+ }
383
387
case IS_RESOURCE : {
384
388
const char * type_name = zend_rsrc_list_get_rsrc_type (Z_RES_P (struc ));
385
389
php_printf ("resource(" ZEND_LONG_FMT ") of type (%s) refcount(%u)\n" , Z_RES_P (struc )-> handle , type_name ? type_name : "Unknown" , Z_REFCOUNT_P (struc ));
@@ -553,17 +557,19 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf) /* {{{ */
553
557
554
558
break ;
555
559
556
- case IS_OBJECT :
560
+ case IS_OBJECT : {
557
561
/* Check if this is already recursing on the object before calling zend_get_properties_for,
558
562
* to allow infinite recursion detection to work even if classes return temporary arrays,
559
563
* and to avoid the need to update the properties table in place to reflect the state
560
564
* if the result won't be used. (https://github.com/php/php-src/issues/8044) */
561
- if (Z_IS_RECURSIVE_P (struc )) {
565
+ zend_object * zobj = Z_OBJ_P (struc );
566
+ uint32_t * guard = zend_get_recursion_guard (zobj );
567
+ if (ZEND_GUARD_OR_GC_IS_RECURSIVE (guard , DEBUG , zobj )) {
562
568
smart_str_appendl (buf , "NULL" , 4 );
563
569
zend_error (E_WARNING , "var_export does not handle circular references" );
564
570
return ;
565
571
}
566
- Z_PROTECT_RECURSION_P ( struc );
572
+ ZEND_GUARD_OR_GC_PROTECT_RECURSION ( guard , DEBUG , zobj );
567
573
myht = zend_get_properties_for (struc , ZEND_PROP_PURPOSE_VAR_EXPORT );
568
574
if (level > 1 ) {
569
575
smart_str_appendc (buf , '\n' );
@@ -597,7 +603,7 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf) /* {{{ */
597
603
}
598
604
zend_release_properties (myht );
599
605
}
600
- Z_UNPROTECT_RECURSION_P ( struc );
606
+ ZEND_GUARD_OR_GC_UNPROTECT_RECURSION ( guard , DEBUG , zobj );
601
607
if (level > 1 && !is_enum ) {
602
608
buffer_append_spaces (buf , level - 1 );
603
609
}
@@ -608,6 +614,7 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf) /* {{{ */
608
614
}
609
615
610
616
break ;
617
+ }
611
618
case IS_REFERENCE :
612
619
struc = Z_REFVAL_P (struc );
613
620
goto again ;
0 commit comments