From 684d18ffc493463eaab09df0f2e69c652141633e Mon Sep 17 00:00:00 2001 From: Ben Thomson Date: Mon, 24 Aug 2020 15:23:49 +0800 Subject: [PATCH] Clean up --- modules/backend/behaviors/RelationController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/backend/behaviors/RelationController.php b/modules/backend/behaviors/RelationController.php index acbf912b1..510242597 100644 --- a/modules/backend/behaviors/RelationController.php +++ b/modules/backend/behaviors/RelationController.php @@ -1125,7 +1125,7 @@ class RelationController extends ControllerBehavior if ($this->relationType === 'hasOne') { // Unassign previous relation if one is already assigned - $relation = $this->relationObject->getParent()->{$this->relationName}; + $relation = $this->relationObject->getParent()->{$this->relationName} ?? null; if ($relation) { $this->relationObject->remove($relation, $sessionKey); @@ -1255,8 +1255,8 @@ class RelationController extends ControllerBehavior elseif ($this->viewMode == 'single') { if ($recordId && ($model = $this->relationModel->find($recordId))) { if ($this->relationType === 'hasOne') { - // Unassign previous relations for singular relation types - $relation = $this->relationObject->getParent()->{$this->relationName}; + // Unassign previous relation if one is already assigned + $relation = $this->relationObject->getParent()->{$this->relationName} ?? null; if ($relation) { $this->relationObject->remove($relation, $sessionKey);