Skip to content

Commit

Permalink
Fix ActiveRelationTrait.php for compatibility 7.4
Browse files Browse the repository at this point in the history
Fix for PHP 7.4

Trying to access array offset on value of type null
When $model is null on Php 7.4:
if (($value = $model[$attribute]) !== null)

/var/www/builds/cms/3.6.0/vendor/yiisoft/yii2/db/ActiveRelationTrait.php line 526

#0 /var/www/builds/cms/3.6.0/vendor/yiisoft/yii2/db/ActiveRelationTrait.php(526): yii\base\ErrorHandler->handleError()
yiisoft#1 /var/www/builds/cms/3.6.0/vendor/yiisoft/yii2/db/ActiveRelationTrait.php(246): yii\db\ActiveQuery->filterByModels()
yiisoft#2 /var/www/builds/cms/3.6.0/vendor/yiisoft/yii2/db/ActiveQueryTrait.php(151): yii\db\ActiveQuery->populateRelation()
yiisoft#3 /var/www/builds/cms/3.6.0/vendor/yiisoft/yii2/db/ActiveQuery.php(224): yii\db\ActiveQuery->findWith()
  • Loading branch information
indrig authored Dec 27, 2019
1 parent 48c08d0 commit b0110ff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion framework/db/ActiveRelationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ private function filterByModels($models)
// single key
$attribute = reset($this->link);
foreach ($models as $model) {
if (($value = $model[$attribute]) !== null) {
if ($model !== null && ($value = $model[$attribute]) !== null) {
if (is_array($value)) {
$values = array_merge($values, $value);
} elseif ($value instanceof ArrayExpression && $value->getDimension() === 1) {
Expand Down

0 comments on commit b0110ff

Please sign in to comment.