new_function = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
memcpy(new_function, func, sizeof(zend_op_array));
- if (ZEND_MAP_PTR_GET(func->op_array.static_variables_ptr)) {
- /* See: Zend/tests/method_static_var.phpt */
- new_function->op_array.static_variables = ZEND_MAP_PTR_GET(func->op_array.static_variables_ptr);
- }
- if (!(GC_FLAGS(new_function->op_array.static_variables) & IS_ARRAY_IMMUTABLE)) {
- GC_ADDREF(new_function->op_array.static_variables);
- }
if (CG(compiler_options) & ZEND_COMPILE_PRELOAD) {
ZEND_ASSERT(new_function->op_array.fn_flags & ZEND_ACC_PRELOADED);
ZEND_MAP_PTR_INIT(new_function->op_array.static_variables_ptr, &new_function->op_array.static_variables);
}
+ HashTable *static_properties_ptr = ZEND_MAP_PTR_GET(func->op_array.static_variables_ptr);
+ if (static_properties_ptr) {
+ /* See: Zend/tests/method_static_var.phpt */
+ ZEND_MAP_PTR_SET(new_function->op_array.static_variables_ptr, static_properties_ptr);
+ GC_TRY_ADDREF(static_properties_ptr);
+ } else {
+ GC_TRY_ADDREF(new_function->op_array.static_variables);
+ }
+
return new_function;
}
/* }}} */
--- /dev/null
+--TEST--
+Preloading inherited method with separated static vars
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.preload={PWD}/preload_method_static_vars.inc
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
+?>
+--FILE--
+<?php
+Foo::test();
+Bar::test();
+?>
+--EXPECT--
+int(1)
+int(2)
+int(2)
+int(3)
+
+int(1)
+int(1)