diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 7bcff0e094..d67780ebaf 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -1,10 +1,10 @@ Yii Framework 2 Change Log ========================== -2.0.43 under development ------------------------- +2.0.42.1 under development +-------------------------- -- no changes in this release. +- Bug #18634: Fix `yii\db\BaseActiveRecord::unlink()` and `unlinkAll()` to omit condition for `on` property when it doesn't exist (bizley) 2.0.42 May 05, 2021 diff --git a/framework/db/BaseActiveRecord.php b/framework/db/BaseActiveRecord.php index c80528c2a2..6555cf2f5d 100644 --- a/framework/db/BaseActiveRecord.php +++ b/framework/db/BaseActiveRecord.php @@ -1413,7 +1413,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface foreach (array_keys($columns) as $a) { $nulls[$a] = null; } - if ($viaRelation->on !== null) { + if (property_exists($viaRelation, 'on') && $viaRelation->on !== null) { $columns = ['and', $columns, $viaRelation->on]; } if (is_array($relation->via)) { @@ -1513,7 +1513,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface if (!empty($viaRelation->where)) { $condition = ['and', $condition, $viaRelation->where]; } - if (!empty($viaRelation->on)) { + if (property_exists($viaRelation, 'on') && !empty($viaRelation->on)) { $condition = ['and', $condition, $viaRelation->on]; } if (is_array($relation->via)) { @@ -1550,7 +1550,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface if (!empty($relation->where)) { $condition = ['and', $condition, $relation->where]; } - if (!empty($relation->on)) { + if (property_exists($relation, 'on') && !empty($relation->on)) { $condition = ['and', $condition, $relation->on]; } if ($delete) {