File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ PHP NEWS
22
22
- Opcache:
23
23
. Fixed bug #81007 (JIT "not supported" on 32-bit x86 -- build problem?).
24
24
(Nikita)
25
+ . Fixed bug #81015 (Opcache optimization assumes wrong part of ternary
26
+ operator in if-condition). (Nikita)
25
27
26
28
- PDO_pgsql:
27
29
. Reverted bug fix for #80892 (PDO::PARAM_INT is treated the same as
Original file line number Diff line number Diff line change @@ -285,6 +285,14 @@ static void place_essa_pis(
285
285
default :
286
286
continue ;
287
287
}
288
+
289
+ /* The following patterns all inspect the opline directly before the JMPZ opcode.
290
+ * Make sure that it is part of the same block, otherwise it might not be a dominating
291
+ * assignment. */
292
+ if (blocks [j ].len == 1 ) {
293
+ continue ;
294
+ }
295
+
288
296
if (opline -> op1_type == IS_TMP_VAR &&
289
297
((opline - 1 )-> opcode == ZEND_IS_EQUAL ||
290
298
(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