Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Fixed bug #81015
This commit is contained in:
Nikita Popov 2021-05-06 10:46:18 +02:00
commit dd3e56ba24
3 changed files with 36 additions and 0 deletions

2
NEWS
View file

@ -22,6 +22,8 @@ PHP NEWS
- Opcache: - Opcache:
. Fixed bug #81007 (JIT "not supported" on 32-bit x86 -- build problem?). . Fixed bug #81007 (JIT "not supported" on 32-bit x86 -- build problem?).
(Nikita) (Nikita)
. Fixed bug #81015 (Opcache optimization assumes wrong part of ternary
operator in if-condition). (Nikita)
- PDO_pgsql: - PDO_pgsql:
. Reverted bug fix for #80892 (PDO::PARAM_INT is treated the same as . Reverted bug fix for #80892 (PDO::PARAM_INT is treated the same as

View file

@ -285,6 +285,14 @@ static void place_essa_pis(
default: default:
continue; continue;
} }
/* The following patterns all inspect the opline directly before the JMPZ opcode.
* Make sure that it is part of the same block, otherwise it might not be a dominating
* assignment. */
if (blocks[j].len == 1) {
continue;
}
if (opline->op1_type == IS_TMP_VAR && if (opline->op1_type == IS_TMP_VAR &&
((opline-1)->opcode == ZEND_IS_EQUAL || ((opline-1)->opcode == ZEND_IS_EQUAL ||
(opline-1)->opcode == ZEND_IS_NOT_EQUAL || (opline-1)->opcode == ZEND_IS_NOT_EQUAL ||

View file

@ -0,0 +1,26 @@
--TEST--
Bug #81015: Opcache optimization assumes wrong part of ternary operator in if-condition
--FILE--
<?php
function ternary(bool $enabled, ?string $value): void
{
// the "true" part is not as trivial in the real case
if ($enabled ? true : $value === null) {
echo ($value ?? 'NULL') . "\n";
} else {
echo "INVALID\n";
}
}
ternary(true, 'value');
ternary(true, null);
ternary(false, 'value');
ternary(false, null);
?>
--EXPECT--
value
NULL
INVALID
NULL