Browse Source

Cleanup.

tags/1.6.0
Alban Jubert 6 years ago
parent
commit
ee2e08a352
  1. 7
      src/SaveRelationsBehavior.php

7
src/SaveRelationsBehavior.php

@ -14,7 +14,6 @@ use yii\base\UnknownPropertyException;
use yii\db\ActiveQuery; use yii\db\ActiveQuery;
use yii\db\BaseActiveRecord; use yii\db\BaseActiveRecord;
use yii\db\Exception as DbException; use yii\db\Exception as DbException;
use yii\db\Transaction;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\helpers\Inflector; use yii\helpers\Inflector;
use yii\helpers\VarDumper; use yii\helpers\VarDumper;
@ -38,7 +37,6 @@ class SaveRelationsBehavior extends Behavior
private $_newRelationValue = []; // Store update relations value private $_newRelationValue = []; // Store update relations value
private $_relationsToDelete = []; private $_relationsToDelete = [];
private $_relationsSaveStarted = false; private $_relationsSaveStarted = false;
private $_transaction;
/** @var BaseActiveRecord[] $_savedHasOneModels */ /** @var BaseActiveRecord[] $_savedHasOneModels */
private $_savedHasOneModels = []; private $_savedHasOneModels = [];
@ -348,7 +346,7 @@ class SaveRelationsBehavior extends Behavior
} }
} catch (Exception $e) { } catch (Exception $e) {
Yii::warning(get_class($e) . ' was thrown while saving related records during beforeValidate event: ' . $e->getMessage(), __METHOD__); Yii::warning(get_class($e) . ' was thrown while saving related records during beforeValidate event: ' . $e->getMessage(), __METHOD__);
$this->_rollback(); // Rollback transaction if any have been started $this->_rollback(); // Rollback saved records during validation process, if any
$model->addError($model->formName(), $e->getMessage()); $model->addError($model->formName(), $e->getMessage());
$event->isValid = false; // Stop saving, something went wrong $event->isValid = false; // Stop saving, something went wrong
return false; return false;
@ -513,9 +511,6 @@ class SaveRelationsBehavior extends Behavior
} }
$owner->refresh(); $owner->refresh();
$this->_relationsSaveStarted = false; $this->_relationsSaveStarted = false;
if (($this->_transaction instanceof Transaction) && $this->_transaction->isActive) {
$this->_transaction->commit();
}
} }
} }

Loading…
Cancel
Save