From 76f9688ea62f423f94673c4367aacd7a3e34a045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 26 Apr 2021 13:57:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Database/ActiveRecord.php | 4 ++++ Database/Base/BaseActiveRecord.php | 5 ++++- System/Channel.php | 4 ---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Database/ActiveRecord.php b/Database/ActiveRecord.php index 4002a6ea..5581c92d 100644 --- a/Database/ActiveRecord.php +++ b/Database/ActiveRecord.php @@ -312,6 +312,10 @@ class ActiveRecord extends BaseActiveRecord $data[$key] = $this->{$item}($data[$key] ?? null); } $data = array_merge($data, $this->runRelate()); + + $class = Snowflake::app()->getChannel(); + $class->push($this, static::class); + return $data; } diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index b89e8811..8052a138 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -1060,8 +1060,11 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess */ public static function populate(array $data): static { + $class = Snowflake::app()->getChannel(); /** @var static $model */ - $model = Snowflake::createObject(static::class); + $model = $class->pop(static::class, function () { + return new static(); + }); $model->_attributes = $data; $model->_oldAttributes = $data; $model->setIsCreate(false); diff --git a/System/Channel.php b/System/Channel.php index e0aee59d..8e3c764f 100644 --- a/System/Channel.php +++ b/System/Channel.php @@ -28,8 +28,6 @@ class Channel extends Component */ public function push(mixed $value, string $name = ''): void { - unset($value); - return; $channel = $this->channelInit($name); $channel->enqueue($value); } @@ -75,8 +73,6 @@ class Channel extends Component */ public function pop(string $name, Closure $closure, int|float $timeout = null): mixed { - return call_user_func($closure); - if (($channel = $this->channelInit($name)) == false) { return $this->addError('Channel is full.'); }