@@ -1167,7 +1167,7 @@ static zend_result spl_heap_unserialize_internal_state(HashTable *state_ht, spl_
1167
1167
return SUCCESS ;
1168
1168
}
1169
1169
1170
- PHP_METHOD ( SplPriorityQueue , __serialize )
1170
+ static void spl_heap_serialize_internal ( INTERNAL_FUNCTION_PARAMETERS , bool is_pqueue )
1171
1171
{
1172
1172
spl_heap_object * intern = Z_SPLHEAP_P (ZEND_THIS );
1173
1173
zval props , state ;
@@ -1185,14 +1185,18 @@ PHP_METHOD(SplPriorityQueue, __serialize)
1185
1185
1186
1186
array_init (return_value );
1187
1187
1188
- ZVAL_ARR (& props , zend_std_get_properties (& intern -> std ));
1189
- Z_TRY_ADDREF (props );
1188
+ ZVAL_ARR (& props , zend_array_dup (zend_std_get_properties (& intern -> std )));
1190
1189
zend_hash_next_index_insert (Z_ARRVAL_P (return_value ), & props );
1191
1190
1192
- spl_heap_serialize_internal_state (& state , intern , true );
1191
+ spl_heap_serialize_internal_state (& state , intern , is_pqueue );
1193
1192
zend_hash_next_index_insert (Z_ARRVAL_P (return_value ), & state );
1194
1193
}
1195
1194
1195
+ PHP_METHOD (SplPriorityQueue , __serialize )
1196
+ {
1197
+ spl_heap_serialize_internal (INTERNAL_FUNCTION_PARAM_PASSTHRU , true);
1198
+ }
1199
+
1196
1200
PHP_METHOD (SplPriorityQueue , __unserialize )
1197
1201
{
1198
1202
HashTable * data ;
@@ -1241,28 +1245,7 @@ PHP_METHOD(SplPriorityQueue, __unserialize)
1241
1245
1242
1246
PHP_METHOD (SplHeap , __serialize )
1243
1247
{
1244
- spl_heap_object * intern = Z_SPLHEAP_P (ZEND_THIS );
1245
- zval props , state ;
1246
-
1247
- ZEND_PARSE_PARAMETERS_NONE ();
1248
-
1249
- if (UNEXPECTED (spl_heap_consistency_validations (intern , false) != SUCCESS )) {
1250
- RETURN_THROWS ();
1251
- }
1252
-
1253
- if (intern -> heap -> flags & SPL_HEAP_WRITE_LOCKED ) {
1254
- zend_throw_exception (spl_ce_RuntimeException , "Cannot serialize heap while it is being modified." , 0 );
1255
- RETURN_THROWS ();
1256
- }
1257
-
1258
- array_init (return_value );
1259
-
1260
- ZVAL_ARR (& props , zend_std_get_properties (& intern -> std ));
1261
- Z_TRY_ADDREF (props );
1262
- zend_hash_next_index_insert (Z_ARRVAL_P (return_value ), & props );
1263
-
1264
- spl_heap_serialize_internal_state (& state , intern , false);
1265
- zend_hash_next_index_insert (Z_ARRVAL_P (return_value ), & state );
1248
+ spl_heap_serialize_internal (INTERNAL_FUNCTION_PARAM_PASSTHRU , false);
1266
1249
}
1267
1250
1268
1251
PHP_METHOD (SplHeap , __unserialize )
0 commit comments