com php-src: Fixed bug #75608 ("Narrowing occurred during type inference" error): NEWS ext/opcache/Optimizer/zend_inference.c ext/o
pcache/tests/bug75608.phpt
| From: | Dmitry Stogov | Date: | Mon, 04 Dec 2017 14:22:06 +0000 |
| Subject: | com php-src: Fixed bug #75608 ("Narrowing occurred during type inference" error): NEWS ext/opcache/Optimizer/zend_inference.c ext/o pcache/tests/bug75608.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100482@lists.php.net to get a copy of this message | ||
Commit: 5934bff91337b876195e9290b0811240052be7a3
Author: Dmitry Stogov <dmitry@zend.com> Mon, 4 Dec 2017 17:22:06 +0300
Parents: 1da28c55c418afe86f6204ecd0d8d28ce235220f
Branches: PHP-7.1 PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5934bff91337b876195e9290b0811240052be7a3
Log:
Fixed bug #75608 ("Narrowing occurred during type inference" error)
Bugs:
https://bugs.php.net/75608
Changed paths:
M NEWS
M ext/opcache/Optimizer/zend_inference.c
A ext/opcache/tests/bug75608.phpt
Diff:
diff --git a/NEWS b/NEWS
index 76c030e..fa23892 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,8 @@ PHP NEWS
requests). (Remi)
- Opcache:
+ . Fixed bug #75608 ("Narrowing occurred during type inference" error).
+ (Laruence, Dmitry)
. Fixed bug #75570 ("Narrowing occurred during type inference" error).
(Dmitry)
diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c
index ef82135..96588f5 100644
--- a/ext/opcache/Optimizer/zend_inference.c
+++ b/ext/opcache/Optimizer/zend_inference.c
@@ -2928,7 +2928,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
break;
case ZEND_FE_FETCH_R:
case ZEND_FE_FETCH_RW:
- tmp = (t2 & MAY_BE_REF);
+ tmp = t2;
if (t1 & MAY_BE_OBJECT) {
if (opline->opcode == ZEND_FE_FETCH_RW) {
tmp |= MAY_BE_REF | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY |
MAY_BE_ARRAY_OF_REF;
@@ -2953,7 +2953,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
}
UPDATE_SSA_TYPE(tmp, ssa_ops[i].op2_def);
if (ssa_ops[i].result_def >= 0) {
- tmp = 0;
+ tmp = (ssa_ops[i].result_use >= 0) ? RES_USE_INFO() : 0;
if (t1 & MAY_BE_OBJECT) {
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;
}
diff --git a/ext/opcache/tests/bug75608.phpt b/ext/opcache/tests/bug75608.phpt
new file mode 100644
index 0000000..875e102
--- /dev/null
+++ b/ext/opcache/tests/bug75608.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Bug #75608 ("Narrowing occurred during type inference" error)
+--FILE--
+<?php
+class ReactionRatingService
+{
+ public function calculateBoostPoints()
+ {
+ while ($reaction = $reactions) {
+ $reactionRatings = $this->validFunction();
+
+ $totalWeight = 0;
+ $runningScore = 0;
+ $queue = [];
+ foreach ($reactionRatings as $ratingData) {
+ if ($runningScore != $reaction['Score']) {
+ if ( ! $ratingData['BoostEarned']) {
+ $queue[] = $ratingData['UserID'];
+ }
+ } else {
+ foreach ($queue as $userId) {
+ $userBoostPointsRecalculate[$userId][] = $reaction['ID'];
+ }
+ }
+ $totalWeight += $ratingData['Weight'];
+ }
+ }
+ }
+}
+?>
+OK
+--EXPECT--
+OK