Skip to content

Commit 3503dc7

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fixed bug #75608 ("Narrowing occurred during type inference" error)
2 parents 5a0eb24 + 5934bff commit 3503dc7

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ PHP NEWS
1818
requests). (Remi)
1919

2020
- Opcache:
21+
. Fixed bug #75608 ("Narrowing occurred during type inference" error).
22+
(Laruence, Dmitry)
2123
. Fixed bug #75570 ("Narrowing occurred during type inference" error).
2224
(Dmitry)
2325
. Fixed bug #75556 (Invalid opcode 138/1/1). (Laruence)

ext/opcache/Optimizer/zend_inference.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2926,7 +2926,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
29262926
break;
29272927
case ZEND_FE_FETCH_R:
29282928
case ZEND_FE_FETCH_RW:
2929-
tmp = (t2 & MAY_BE_REF);
2929+
tmp = t2;
29302930
if (t1 & MAY_BE_OBJECT) {
29312931
if (opline->opcode == ZEND_FE_FETCH_RW) {
29322932
tmp |= MAY_BE_REF | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
@@ -2951,7 +2951,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
29512951
}
29522952
UPDATE_SSA_TYPE(tmp, ssa_ops[i].op2_def);
29532953
if (ssa_ops[i].result_def >= 0) {
2954-
tmp = 0;
2954+
tmp = (ssa_ops[i].result_use >= 0) ? RES_USE_INFO() : 0;
29552955
if (t1 & MAY_BE_OBJECT) {
29562956
tmp |= MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
29572957
}

ext/opcache/tests/bug75608.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #75608 ("Narrowing occurred during type inference" error)
3+
--FILE--
4+
<?php
5+
class ReactionRatingService
6+
{
7+
public function calculateBoostPoints()
8+
{
9+
while ($reaction = $reactions) {
10+
$reactionRatings = $this->validFunction();
11+
12+
$totalWeight = 0;
13+
$runningScore = 0;
14+
$queue = [];
15+
foreach ($reactionRatings as $ratingData) {
16+
if ($runningScore != $reaction['Score']) {
17+
if ( ! $ratingData['BoostEarned']) {
18+
$queue[] = $ratingData['UserID'];
19+
}
20+
} else {
21+
foreach ($queue as $userId) {
22+
$userBoostPointsRecalculate[$userId][] = $reaction['ID'];
23+
}
24+
}
25+
$totalWeight += $ratingData['Weight'];
26+
}
27+
}
28+
}
29+
}
30+
?>
31+
OK
32+
--EXPECT--
33+
OK

0 commit comments

Comments
 (0)