From 80ea6df3675440b4120fe7a14693f42e7326027e Mon Sep 17 00:00:00 2001 From: Hanqing Sun Date: Sat, 29 Jul 2017 20:41:13 +0800 Subject: [PATCH] =?UTF-8?q?Collection::append()=20=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8(null)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调用collection()->append(['关联'=>['属性']]),如果遇到某个模型对象的关联查询到null,则append会导致null object错误 --- library/think/model/Collection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/think/model/Collection.php b/library/think/model/Collection.php index 4e4bb4dc..e5f9ceec 100644 --- a/library/think/model/Collection.php +++ b/library/think/model/Collection.php @@ -85,7 +85,7 @@ class Collection extends BaseCollection { $this->each(function ($model) use ($append, $override) { /** @var Model $model */ - $model->append($append, $override); + $model && $model->append($append, $override); }); return $this; }