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.'); }