From 79deb9438fec8f4d5f8fdf844f56a7db3883c459 Mon Sep 17 00:00:00 2001 From: Alban Jubert Date: Sat, 22 Jun 2019 16:38:34 +0200 Subject: [PATCH] Small optimization --- src/SaveRelationsBehavior.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SaveRelationsBehavior.php b/src/SaveRelationsBehavior.php index dd3131c..e580be1 100644 --- a/src/SaveRelationsBehavior.php +++ b/src/SaveRelationsBehavior.php @@ -326,7 +326,9 @@ class SaveRelationsBehavior extends Behavior */ public function afterValidate() { - if ($this->owner->hasErrors() && !empty($this->_savedHasOneModels)) { + /* @var $model BaseActiveRecord */ + $model = $this->owner; + if (!empty($this->_savedHasOneModels) && $model->hasErrors()) { $this->_rollbackSavedHasOneModels(); } }