@@ -626,6 +626,7 @@ static zend_object_value date_object_clone_period(zval *this_ptr TSRMLS_DC);
626
626
static int date_object_compare_date (zval * d1 , zval * d2 TSRMLS_DC );
627
627
static HashTable * date_object_get_gc (zval * object , zval * * * table , int * n TSRMLS_DC );
628
628
static HashTable * date_object_get_properties (zval * object TSRMLS_DC );
629
+ static HashTable * date_object_get_debug_info (zval * object , int * temp TSRMLS_DC );
629
630
static HashTable * date_object_get_gc_interval (zval * object , zval * * * table , int * n TSRMLS_DC );
630
631
static HashTable * date_object_get_properties_interval (zval * object TSRMLS_DC );
631
632
static HashTable * date_object_get_gc_period (zval * object , zval * * * table , int * n TSRMLS_DC );
@@ -1993,7 +1994,8 @@ static void date_register_classes(TSRMLS_D)
1993
1994
memcpy (& date_object_handlers_date , zend_get_std_object_handlers (), sizeof (zend_object_handlers ));
1994
1995
date_object_handlers_date .clone_obj = date_object_clone_date ;
1995
1996
date_object_handlers_date .compare_objects = date_object_compare_date ;
1996
- date_object_handlers_date .get_properties = date_object_get_properties ;
1997
+ date_object_handlers_date .get_debug_info = date_object_get_debug_info ;
1998
+ date_object_handlers_date .get_serialize_info = date_object_get_properties ;
1997
1999
date_object_handlers_date .get_gc = date_object_get_gc ;
1998
2000
zend_class_implements (date_ce_date TSRMLS_CC , 1 , date_ce_interface );
1999
2001
@@ -2180,6 +2182,12 @@ static HashTable *date_object_get_gc_timezone(zval *object, zval ***table, int *
2180
2182
return zend_std_get_properties (object TSRMLS_CC );
2181
2183
}
2182
2184
2185
+ static HashTable * date_object_get_debug_info (zval * object , int * temp TSRMLS_DC )
2186
+ {
2187
+ * temp = 0 ;
2188
+ return date_object_get_properties (object TSRMLS_CC );
2189
+ }
2190
+
2183
2191
static HashTable * date_object_get_properties (zval * object TSRMLS_DC )
2184
2192
{
2185
2193
HashTable * props ;
@@ -2195,16 +2203,22 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
2195
2203
return props ;
2196
2204
}
2197
2205
2206
+ if (!dateobj -> props ) {
2207
+ ALLOC_HASHTABLE (dateobj -> props );
2208
+ ZEND_INIT_SYMTABLE_EX (dateobj -> props , 3 , 0 );
2209
+ }
2210
+ zend_hash_merge (dateobj -> props , props , (copy_ctor_func_t ) zval_add_ref , NULL , sizeof (zval * ), 0 );
2211
+
2198
2212
/* first we add the date and time in ISO format */
2199
2213
MAKE_STD_ZVAL (zv );
2200
2214
ZVAL_STRING (zv , date_format ("Y-m-d H:i:s" , 12 , dateobj -> time , 1 ), 0 );
2201
- zend_hash_update (props , "date" , 5 , & zv , sizeof (zval ), NULL );
2215
+ zend_hash_update (dateobj -> props , "date" , sizeof ( "date" ) , & zv , sizeof (zval ), NULL );
2202
2216
2203
2217
/* then we add the timezone name (or similar) */
2204
2218
if (dateobj -> time -> is_localtime ) {
2205
2219
MAKE_STD_ZVAL (zv );
2206
2220
ZVAL_LONG (zv , dateobj -> time -> zone_type );
2207
- zend_hash_update (props , "timezone_type" , 14 , & zv , sizeof (zval ), NULL );
2221
+ zend_hash_update (dateobj -> props , "timezone_type" , sizeof ( "timezone_type" ) , & zv , sizeof (zval ), NULL );
2208
2222
2209
2223
MAKE_STD_ZVAL (zv );
2210
2224
switch (dateobj -> time -> zone_type ) {
@@ -2227,10 +2241,10 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
2227
2241
ZVAL_STRING (zv , dateobj -> time -> tz_abbr , 1 );
2228
2242
break ;
2229
2243
}
2230
- zend_hash_update (props , "timezone" , 9 , & zv , sizeof (zval ), NULL );
2244
+ zend_hash_update (dateobj -> props , "timezone" , sizeof ( "timezone" ) , & zv , sizeof (zval ), NULL );
2231
2245
}
2232
2246
2233
- return props ;
2247
+ return dateobj -> props ;
2234
2248
}
2235
2249
2236
2250
static inline zend_object_value date_object_new_timezone_ex (zend_class_entry * class_type , php_timezone_obj * * ptr TSRMLS_DC )
@@ -2465,6 +2479,10 @@ static void date_object_free_storage_date(void *object TSRMLS_DC)
2465
2479
if (intern -> time ) {
2466
2480
timelib_time_dtor (intern -> time );
2467
2481
}
2482
+ if (intern -> props ) {
2483
+ zend_hash_destroy (intern -> props );
2484
+ FREE_HASHTABLE (intern -> props );
2485
+ }
2468
2486
2469
2487
zend_object_std_dtor (& intern -> std TSRMLS_CC );
2470
2488
efree (object );
0 commit comments