1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' of https://github.com/php/php-src into PHP-8.3

This commit is contained in:
Bob Weinand
2024-03-18 19:04:12 +01:00
4 changed files with 27 additions and 2 deletions

2
NEWS
View File

@@ -29,6 +29,8 @@ PHP NEWS
- Opcache:
. Fixed GH-13508 (JITed QM_ASSIGN may be optimized out when op1 is null).
(Arnaud, Dmitry)
. Fixed GH-13712 (Segmentation fault for enabled observers when calling trait
method of internal trait when opcache is loaded). (Bob)
- Random:
. Fixed bug GH-13544 (Pre-PHP 8.2 compatibility for mt_srand with unknown

View File

@@ -1993,9 +1993,9 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_
} else {
new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
memcpy(new_fn, fn, sizeof(zend_op_array));
new_fn->op_array.fn_flags |= ZEND_ACC_TRAIT_CLONE;
new_fn->op_array.fn_flags &= ~ZEND_ACC_IMMUTABLE;
}
new_fn->common.fn_flags |= ZEND_ACC_TRAIT_CLONE;
/* Reassign method name, in case it is an alias. */
new_fn->common.function_name = name;

View File

@@ -0,0 +1,23 @@
--TEST--
GH-13712 (Segmentation fault for enabled observers when calling trait method of internal trait when opcache is loaded)
--EXTENSIONS--
opcache
zend_test
--INI--
zend_test.observer.enabled=1
opcache.enable=1
opcache.enable_cli=1
--FILE--
<?php
class Foo {
use _ZendTestTrait;
}
$f = new Foo();
var_dump($f->testMethod());
?>
--EXPECTF--
<!-- init '%s' -->
<!-- init Foo::testMethod() -->
<!-- init var_dump() -->
bool(true)

View File

@@ -729,7 +729,7 @@ static void zend_persist_class_method(zval *zv, zend_class_entry *ce)
}
// Real dynamically created internal functions like enum methods must have their own run_time_cache pointer. They're always on the same scope as their defining class.
// However, copies - as caused by inheritance of internal methods - must retain the original run_time_cache pointer, shared with the source function.
if (!op_array->scope || op_array->scope == ce) {
if (!op_array->scope || (op_array->scope == ce && !(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE))) {
ZEND_MAP_PTR_NEW(op_array->run_time_cache);
}
}