Skip to content

Commit 719d413

Browse files
committed
Fix opcache
1 parent dfb44f6 commit 719d413

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

Zend/Optimizer/sccp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,11 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
11061106

11071107
if (op2) {
11081108
SKIP_IF_TOP(op2);
1109+
if (Z_TYPE_P(op2) == IS_NULL) {
1110+
/* Emits deprecation at run-time. */
1111+
SET_RESULT_BOT(result);
1112+
return;
1113+
}
11091114
}
11101115

11111116
/* We want to avoid keeping around intermediate arrays for each SSA variable in the
@@ -2290,7 +2295,7 @@ static int try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var,
22902295
break;
22912296
case ZEND_INIT_ARRAY:
22922297
case ZEND_ADD_ARRAY_ELEMENT:
2293-
if (opline->op2_type == IS_UNUSED) {
2298+
if (opline->op2_type == IS_UNUSED || opline->op2_type == IS_NULL) {
22942299
return 0;
22952300
}
22962301
/* break missing intentionally */

Zend/Optimizer/zend_inference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5252,7 +5252,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
52525252
case ZEND_INIT_ARRAY:
52535253
return (opline->op2_type != IS_UNUSED) && (t2 & (MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
52545254
case ZEND_ADD_ARRAY_ELEMENT:
5255-
return (opline->op2_type == IS_UNUSED) || (t2 & (MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
5255+
return (opline->op2_type == IS_UNUSED) || (t2 & (MAY_BE_NULL|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
52565256
case ZEND_STRLEN:
52575257
return (t1 & MAY_BE_ANY) != MAY_BE_STRING;
52585258
case ZEND_COUNT:

Zend/tests/offsets/gh20194.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
GH-20194: Using null as an array offset does not emit deprecation when resolved at compile time
3-
--INI--
4-
opcache.opt_debug_level=0x20000
53
--FILE--
64
<?php
75

0 commit comments

Comments
 (0)