Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ PHP NEWS
(henderkes)
. Fixed bug GH-20767 (build failure with musttail/preserve_none feature
on macOs). (David Carlier)
. Fix deprecation now showing when accessing null key of an array with JIT.
(alexandre-daubois)

- MbString:
. Fixed bug GH-20833 (mb_str_pad() divide by zero if padding string is
Expand Down
12 changes: 12 additions & 0 deletions Zend/Optimizer/sccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,12 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
SKIP_IF_TOP(op1);
SKIP_IF_TOP(op2);

if (op2 && Z_TYPE_P(op2) == IS_NULL) {
/* Emits deprecation at run-time. */
SET_RESULT_BOT(result);
break;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to move this to fetch_array_elem?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @iluuu1994. It's better to move this code into fetch_array_elem() and ct_eval_isset_dim().
This should also fix deprecation for ZEND_ASSIGN_DIM_OP.

if (ct_eval_fetch_dim(&zv, op1, op2, (opline->opcode != ZEND_FETCH_LIST_R)) == SUCCESS) {
SET_RESULT(result, &zv);
zval_ptr_dtor_nogc(&zv);
Expand All @@ -1546,6 +1552,12 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
SKIP_IF_TOP(op1);
SKIP_IF_TOP(op2);

if (op2 && Z_TYPE_P(op2) == IS_NULL) {
/* Emits deprecation at run-time. */
SET_RESULT_BOT(result);
break;
}

if (ct_eval_isset_dim(&zv, opline->extended_value, op1, op2) == SUCCESS) {
SET_RESULT(result, &zv);
zval_ptr_dtor_nogc(&zv);
Expand Down
4 changes: 3 additions & 1 deletion ext/opcache/tests/jit/fetch_dim_r_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ function foo() {
}
foo();
?>
--EXPECT--
--EXPECTF--
int(1)
int(3)
int(2)
int(1)
int(3)
int(1)
int(2)

Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(4)
int(5)
int(5)
Expand Down
Loading