File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -284,6 +284,14 @@ static void place_essa_pis(
284
284
default :
285
285
continue ;
286
286
}
287
+
288
+ /* The following patterns all inspect the opline directly before the JMPZ opcode.
289
+ * Make sure that it is part of the same block, otherwise it might not be a dominating
290
+ * assignment. */
291
+ if (blocks [j ].len == 1 ) {
292
+ continue ;
293
+ }
294
+
287
295
if (opline -> op1_type == IS_TMP_VAR &&
288
296
((opline - 1 )-> opcode == ZEND_IS_EQUAL ||
289
297
(opline - 1 )-> opcode == ZEND_IS_NOT_EQUAL ||
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #81015: Opcache optimization assumes wrong part of ternary operator in if-condition
3
+ --FILE--
4
+ <?php
5
+
6
+ function ternary (bool $ enabled , ?string $ value ): void
7
+ {
8
+ // the "true" part is not as trivial in the real case
9
+ if ($ enabled ? true : $ value === null ) {
10
+ echo ($ value ?? 'NULL ' ) . "\n" ;
11
+ } else {
12
+ echo "INVALID \n" ;
13
+ }
14
+ }
15
+
16
+ ternary (true , 'value ' );
17
+ ternary (true , null );
18
+ ternary (false , 'value ' );
19
+ ternary (false , null );
20
+
21
+ ?>
22
+ --EXPECT--
23
+ value
24
+ NULL
25
+ INVALID
26
+ NULL
You can’t perform that action at this time.
0 commit comments