Skip to content

Commit 3fc0e2b

Browse files
committed
Fixed bug #78376 (Incorrect preloading of constant static properties)
1 parent 790b0b1 commit 3fc0e2b

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ PHP NEWS
2727

2828
- Opcache:
2929
. Fixed bug #78341 (Failure to detect smart branch in DFA pass). (Nikita)
30+
. Fixed bug #78376 (Incorrect preloading of constant static properties).
31+
(Dmitry)
3032

3133
- PCRE:
3234
. Fixed bug #78338 (Array cross-border reading in PCRE). (cmb)

ext/opcache/ZendAccelerator.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4268,6 +4268,16 @@ static int accel_preload(const char *config)
42684268
ZEND_ASSERT(ce->ce_flags & ZEND_ACC_PRELOADED);
42694269
if (ce->default_static_members_count) {
42704270
zend_cleanup_internal_class_data(ce);
4271+
if (ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED) {
4272+
int i;
4273+
4274+
for (i = 0; i < ce->default_static_members_count; i++) {
4275+
if (Z_TYPE(ce->default_static_members_table[i]) == IS_CONSTANT_AST) {
4276+
ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED;
4277+
break;
4278+
}
4279+
}
4280+
}
42714281
}
42724282
if (ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS) {
42734283
zend_op_array *op_array;

ext/opcache/tests/bug78376.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #78376 (Incorrect preloading of constant static properties)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
opcache.preload={PWD}/preload_bug78376.inc
8+
--SKIPIF--
9+
<?php require_once('skipif.inc'); ?>
10+
--FILE--
11+
<?php
12+
var_dump(\A::$a);
13+
?>
14+
--EXPECT--
15+
string(4) "aaaa"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
const CNST = 'aaaa';
3+
class A {
4+
public static $a = CNST;
5+
}
6+
$a = \A::$a;

0 commit comments

Comments
 (0)