From 1b15ff0479aa60c18b6ab9b6d66e4ed66bf96e33 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 16 Oct 2018 18:55:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E4=BF=AE=E6=94=B9=E5=99=A8?= =?UTF-8?q?=E4=BC=9A=E6=89=A7=E8=A1=8C=E5=A4=9A=E6=AC=A1=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 1 + library/think/model/concern/Attribute.php | 15 ++++++++++++--- library/think/route/Domain.php | 1 - 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 81834d590a..93914f0d6c 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -439,6 +439,7 @@ public function save($data = [], $where = [], $sequence = null) // 重新记录原始数据 $this->origin = $this->data; + $this->set = []; return true; } diff --git a/library/think/model/concern/Attribute.php b/library/think/model/concern/Attribute.php index 9b06b9ad0e..76342b9f3c 100644 --- a/library/think/model/concern/Attribute.php +++ b/library/think/model/concern/Attribute.php @@ -72,6 +72,12 @@ trait Attribute */ private $data = []; + /** + * 修改器执行记录 + * @var array + */ + private $set = []; + /** * 原始数据 * @var array @@ -304,10 +310,14 @@ public function getChangedData() * @param string $name 属性名 * @param mixed $value 属性值 * @param array $data 数据 - * @return $this + * @return void */ public function setAttr($name, $value, $data = []) { + if (isset($this->set[$name])) { + return; + } + if (is_null($value) && $this->autoWriteTimestamp && in_array($name, [$this->createTime, $this->updateTime])) { // 自动写入的时间戳字段 $value = $this->autoWriteTimestamp($name); @@ -325,8 +335,7 @@ public function setAttr($name, $value, $data = []) // 设置数据对象属性 $this->data[$name] = $value; - - return $this; + $this->set[$name] = true; } /** diff --git a/library/think/route/Domain.php b/library/think/route/Domain.php index 2e4356f4e9..80950dc281 100644 --- a/library/think/route/Domain.php +++ b/library/think/route/Domain.php @@ -20,7 +20,6 @@ class Domain extends RuleGroup { - /** * 架构函数 * @access public