Skip to content

Commit 0905a31

Browse files
Core: fix missing deprecation when accessing null array key with JIT
1 parent e9ae040 commit 0905a31

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

Zend/Optimizer/sccp.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,12 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
15351535
SKIP_IF_TOP(op1);
15361536
SKIP_IF_TOP(op2);
15371537

1538+
if (op2 && Z_TYPE_P(op2) == IS_NULL) {
1539+
/* Emits deprecation at run-time. */
1540+
SET_RESULT_BOT(result);
1541+
break;
1542+
}
1543+
15381544
if (ct_eval_fetch_dim(&zv, op1, op2, (opline->opcode != ZEND_FETCH_LIST_R)) == SUCCESS) {
15391545
SET_RESULT(result, &zv);
15401546
zval_ptr_dtor_nogc(&zv);
@@ -1546,6 +1552,12 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
15461552
SKIP_IF_TOP(op1);
15471553
SKIP_IF_TOP(op2);
15481554

1555+
if (op2 && Z_TYPE_P(op2) == IS_NULL) {
1556+
/* Emits deprecation at run-time. */
1557+
SET_RESULT_BOT(result);
1558+
break;
1559+
}
1560+
15491561
if (ct_eval_isset_dim(&zv, opline->extended_value, op1, op2) == SUCCESS) {
15501562
SET_RESULT(result, &zv);
15511563
zval_ptr_dtor_nogc(&zv);

ext/opcache/tests/jit/fetch_dim_r_001.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ function foo() {
3030
}
3131
foo();
3232
?>
33-
--EXPECT--
33+
--EXPECTF--
3434
int(1)
3535
int(3)
3636
int(2)
3737
int(1)
3838
int(3)
3939
int(1)
4040
int(2)
41+
42+
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
4143
int(4)
4244
int(5)
4345
int(5)

0 commit comments

Comments
 (0)