Fix #18634: Fix yii\db\BaseActiveRecord::unlink() and unlinkAll() to omit condition for on property when it doesn't exist

This commit is contained in:
Bizley
2021-05-06 12:04:40 +02:00
committed by GitHub
parent 3a58026359
commit 52cf02d685
2 changed files with 6 additions and 6 deletions

View File

@ -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

View File

@ -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) {