From 467596633d3b3dd271d0213fbbffba41e3293982 Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Tue, 26 May 2015 12:00:28 +0300 Subject: [PATCH] Code optimization --- framework/db/BaseActiveRecord.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/framework/db/BaseActiveRecord.php b/framework/db/BaseActiveRecord.php index a479819d9b..a99fdd510d 100644 --- a/framework/db/BaseActiveRecord.php +++ b/framework/db/BaseActiveRecord.php @@ -721,13 +721,14 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface throw new StaleObjectException('The object being updated is outdated.'); } + if (isset($values[$lock])) { + $this->$lock = $values[$lock]; + } + $changedAttributes = []; foreach ($values as $name => $value) { $changedAttributes[$name] = isset($this->_oldAttributes[$name]) ? $this->_oldAttributes[$name] : null; $this->_oldAttributes[$name] = $value; - if ($name === $lock) { - $this->$lock = $value; - } } $this->afterSave(false, $changedAttributes);