@@ -1167,7 +1167,7 @@ static zend_result spl_heap_unserialize_internal_state(HashTable *state_ht, spl_
11671167 return SUCCESS ;
11681168}
11691169
1170- PHP_METHOD ( SplPriorityQueue , __serialize )
1170+ static void spl_heap_serialize_internal ( INTERNAL_FUNCTION_PARAMETERS , bool is_pqueue )
11711171{
11721172 spl_heap_object * intern = Z_SPLHEAP_P (ZEND_THIS );
11731173 zval props , state ;
@@ -1185,14 +1185,18 @@ PHP_METHOD(SplPriorityQueue, __serialize)
11851185
11861186 array_init (return_value );
11871187
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 )));
11901189 zend_hash_next_index_insert (Z_ARRVAL_P (return_value ), & props );
11911190
1192- spl_heap_serialize_internal_state (& state , intern , true );
1191+ spl_heap_serialize_internal_state (& state , intern , is_pqueue );
11931192 zend_hash_next_index_insert (Z_ARRVAL_P (return_value ), & state );
11941193}
11951194
1195+ PHP_METHOD (SplPriorityQueue , __serialize )
1196+ {
1197+ spl_heap_serialize_internal (INTERNAL_FUNCTION_PARAM_PASSTHRU , true);
1198+ }
1199+
11961200PHP_METHOD (SplPriorityQueue , __unserialize )
11971201{
11981202 HashTable * data ;
@@ -1241,28 +1245,7 @@ PHP_METHOD(SplPriorityQueue, __unserialize)
12411245
12421246PHP_METHOD (SplHeap , __serialize )
12431247{
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);
12661249}
12671250
12681251PHP_METHOD (SplHeap , __unserialize )
0 commit comments