Skip to content

Commit d6a8a5a

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #78376 (Incorrect preloading of constant static properties)
2 parents 6326717 + 3fc0e2b commit d6a8a5a

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4322,6 +4322,16 @@ static int accel_preload(const char *config)
43224322
ZEND_ASSERT(ce->ce_flags & ZEND_ACC_PRELOADED);
43234323
if (ce->default_static_members_count) {
43244324
zend_cleanup_internal_class_data(ce);
4325+
if (ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED) {
4326+
int i;
4327+
4328+
for (i = 0; i < ce->default_static_members_count; i++) {
4329+
if (Z_TYPE(ce->default_static_members_table[i]) == IS_CONSTANT_AST) {
4330+
ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED;
4331+
break;
4332+
}
4333+
}
4334+
}
43254335
}
43264336
if (ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS) {
43274337
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)