From c13f8fd35f02555d137b88cc5a9b2716e8723617 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Fri, 9 Jan 2026 11:33:02 +0100 Subject: [PATCH] Core: fix missing deprecation when accessing null array key with JIT --- NEWS | 2 ++ Zend/Optimizer/sccp.c | 12 ++++++++++++ ext/opcache/tests/jit/fetch_dim_r_001.phpt | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 5a03492c24203..a57698930b811 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/Zend/Optimizer/sccp.c b/Zend/Optimizer/sccp.c index 7e2fc2db1b256..643e79d68ba35 100644 --- a/Zend/Optimizer/sccp.c +++ b/Zend/Optimizer/sccp.c @@ -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; + } + if (ct_eval_fetch_dim(&zv, op1, op2, (opline->opcode != ZEND_FETCH_LIST_R)) == SUCCESS) { SET_RESULT(result, &zv); 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 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); diff --git a/ext/opcache/tests/jit/fetch_dim_r_001.phpt b/ext/opcache/tests/jit/fetch_dim_r_001.phpt index 3ff56263db683..819ec7edca655 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_001.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_001.phpt @@ -30,7 +30,7 @@ function foo() { } foo(); ?> ---EXPECT-- +--EXPECTF-- int(1) int(3) int(2) @@ -38,6 +38,8 @@ 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)