From f9838f781d4f3c95dd6811b2e78b1eef51098c38 Mon Sep 17 00:00:00 2001 From: Administrator Date: Fri, 17 Dec 2021 04:23:12 +0800 Subject: [PATCH] 1 --- kiri-engine/Context.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kiri-engine/Context.php b/kiri-engine/Context.php index f70aeb63..b253fd71 100644 --- a/kiri-engine/Context.php +++ b/kiri-engine/Context.php @@ -38,6 +38,9 @@ class Context extends BaseContext */ public static function increment($id, int $value = 1, $coroutineId = null): bool|int { + if (is_null($coroutineId)) { + $coroutineId = Coroutine::getCid(); + } if (!isset(Coroutine::getContext($coroutineId)[$id])) { Coroutine::getContext($coroutineId)[$id] = 0; } @@ -52,6 +55,9 @@ class Context extends BaseContext */ public static function decrement($id, int $value = 1, $coroutineId = null): bool|int { + if (is_null($coroutineId)) { + $coroutineId = Coroutine::getCid(); + } if (!isset(Coroutine::getContext($coroutineId)[$id])) { Coroutine::getContext($coroutineId)[$id] = 0; } @@ -81,6 +87,9 @@ class Context extends BaseContext */ private static function loadByContext($id, $default = null, $coroutineId = null): mixed { + if (is_null($coroutineId)) { + $coroutineId = Coroutine::getCid(); + } return Coroutine::getContext($coroutineId)[$id] ?? $default; }