From 7ee78a964215a591374a88a703e61ccc0c70ee8b Mon Sep 17 00:00:00 2001 From: Administrator Date: Fri, 17 Dec 2021 04:24:01 +0800 Subject: [PATCH] 1 --- kiri-engine/Context.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kiri-engine/Context.php b/kiri-engine/Context.php index b253fd71..f5afa08a 100644 --- a/kiri-engine/Context.php +++ b/kiri-engine/Context.php @@ -24,10 +24,13 @@ class Context extends BaseContext */ public static function setContext($id, $context, $coroutineId = null): mixed { - if (Coroutine::getCid() === -1) { - return static::$_contents[$id] = $context; - } - return Coroutine::getContext($coroutineId)[$id] = $context; + if (is_null($coroutineId)) { + $coroutineId = Coroutine::getCid(); + } + if (Coroutine::getCid() !== -1) { + return Coroutine::getContext($coroutineId)[$id] = $context; + } + return static::$_contents[$id] = $context; } /**