aports/testing/php85-pecl-runkit7/fix-tests85.patch
2025-12-30 21:14:13 +00:00

42 lines
2.2 KiB
Diff

diff --git a/runkit_functions.c b/runkit_functions.c
index b46d25f..12139dc 100644
--- a/runkit_functions.c
+++ b/runkit_functions.c
@@ -422,17 +422,23 @@ static void php_runkit_function_copy_ctor_same_type(zend_function *fe, zend_stri
// TODO: Look into other php 7.4 changes required for d57cd36e47b627dee5b825760163f8e62e23ab28
if (op_array->static_variables) {
- // Similar to zend_closures.c's zend_create_closure copying static variables, zend_compile.c's do_bind_function
+ HashTable *static_vars = op_array->static_variables;
+#if PHP_VERSION_ID >= 80200
+ /* For closures with 'use' vars, copy bound values from runtime map */
+ if ((fe->common.fn_flags & ZEND_ACC_CLOSURE) && ZEND_MAP_PTR_GET(op_array->static_variables_ptr)) {
+ static_vars = ZEND_MAP_PTR_GET(op_array->static_variables_ptr);
+ }
+ /* Use new map slot to prevent sharing state with original */
+ ZEND_MAP_PTR_NEW(op_array->static_variables_ptr);
+#endif
// TODO: Does that work with references?
// 979: This seems to be calling an internal function returning a reference, then crashing?
// ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
// ? Z_ISREF_P(ret) : !Z_ISREF_P(ret));
- op_array->static_variables = zend_array_dup(op_array->static_variables);
+ op_array->static_variables = zend_array_dup(static_vars);
#if PHP_VERSION_ID >= 70400
#if PHP_VERSION_ID >= 80200
- /* zend_shutdown_executor_values frees static_variables, destroy_op_array frees static_variables_ptr */
- HashTable *ht_dup = zend_array_dup(op_array->static_variables);
- ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, ht_dup);
+ ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, zend_array_dup(op_array->static_variables));
#else
ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, &(op_array->static_variables));
#endif
@@ -444,6 +450,7 @@ static void php_runkit_function_copy_ctor_same_type(zend_function *fe, zend_stri
run_time_cache = pemalloc(op_array->cache_size, 1);
memset(run_time_cache, 0, op_array->cache_size);
#ifdef ZEND_MAP_PTR_SET
+ ZEND_MAP_PTR_NEW(op_array->run_time_cache);
ZEND_MAP_PTR_SET(op_array->run_time_cache, run_time_cache);
#else
op_array->run_time_cache = run_time_cache;