Skip to content

Commit 6ef7e53

Browse files
committed
Fixed bug #78961 (erroneous optimization of re-assigned $GLOBALS)
1 parent 7e9e093 commit 6ef7e53

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PHP NEWS
88
(Alexey Kachalin)
99

1010
- OPcache:
11+
. Fixed bug #78961 (erroneous optimization of re-assigned $GLOBALS). (Dmitry)
1112
. Fixed bug #78950 (Preloading trait method with static variables). (Nikita)
1213
. Fixed bug #78903 (Conflict in RTD key for closures results in crash).
1314
(Nikita)

ext/opcache/Optimizer/pass1_5.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
515515
zend_optimizer_collect_constant(ctx, &ZEND_OP1_LITERAL(opline), &ZEND_OP2_LITERAL(opline));
516516
}
517517
break;
518+
#if 0
519+
/* see ext/opcache/tests/bug78961.phpt */
518520
// case ZEND_FETCH_R:
519521
case ZEND_FETCH_W:
520522
// case ZEND_FETCH_RW:
@@ -558,6 +560,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
558560
MAKE_NOP(opline);
559561
}
560562
break;
563+
#endif
561564

562565
case ZEND_RETURN:
563566
case ZEND_RETURN_BY_REF:

ext/opcache/tests/bug78961.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #78961 (erroneous optimization of re-assigned $GLOBALS)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
--FILE--
10+
<?php
11+
$GLOBALS = array();
12+
$GLOBALS['td'] = array();
13+
$GLOBALS['td']['nsno'] = 3;
14+
var_dump($GLOBALS['td']['nsno']);
15+
?>
16+
--EXPECT--
17+
int(3)

0 commit comments

Comments
 (0)