Fix #19469: Fix a virtual relation not working because of new isset checks in \yii\db\ActiveRelationTrait

This commit is contained in:
Winus van Heumen
2022-07-15 22:52:39 +02:00
committed by GitHub
parent dcb0750587
commit adadbefe88
4 changed files with 22 additions and 2 deletions

View File

@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.46 under development
------------------------
- Bug #19469: Fix a virtual relation not working because of new isset checks in `\yii\db\ActiveRelationTrait` (wvanheumen)
- Bug #19380: Fix PHP 8.1 passing non string to trim() in `yii\db\Query` (wa1kb0y)
- Bug #19272: Fix bug in dirty attributes check on multidimensional array (speedplli)
- Bug #19349: Fix PHP 8.1 error when attribute and label of `yii\grid\DataColumn` are empty (githubjeka)

View File

@ -528,7 +528,7 @@ trait ActiveRelationTrait
// single key
$attribute = reset($this->link);
foreach ($models as $model) {
$value = isset($model[$attribute]) ? $model[$attribute] : null;
$value = isset($model[$attribute]) || (is_object($model) && property_exists($model, $attribute)) ? $model[$attribute] : null;
if ($value !== null) {
if (is_array($value)) {
$values = array_merge($values, $value);
@ -586,7 +586,7 @@ trait ActiveRelationTrait
{
$key = [];
foreach ($attributes as $attribute) {
if (isset($model[$attribute])) {
if (isset($model[$attribute]) || (is_object($model) && property_exists($model, $attribute))) {
$key[] = $this->normalizeModelKey($model[$attribute]);
}
}