diff --git a/CHANGELOG-2.0.md b/CHANGELOG-2.0.md index 1e0d3112d..00873f80c 100644 --- a/CHANGELOG-2.0.md +++ b/CHANGELOG-2.0.md @@ -44,6 +44,7 @@ ## Fixed - [#1825](https://github.com/hyperf/hyperf/pull/1825) Fixed `TypeError` for `StartServer::execute`. +- [#1854](https://github.com/hyperf/hyperf/pull/1854) Fixed `is_resource` does not works when use `Runtime::enableCoroutine()` privately in filesystem. ## Optimized diff --git a/src/filesystem/src/Adapter/AliyunOssHook.php b/src/filesystem/src/Adapter/AliyunOssHook.php index 6a44bf345..edf5389bc 100644 --- a/src/filesystem/src/Adapter/AliyunOssHook.php +++ b/src/filesystem/src/Adapter/AliyunOssHook.php @@ -10,12 +10,11 @@ declare(strict_types=1); * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ namespace Oss\OssClient { + use Swoole\Runtime; + function is_resource($resource) { - if (! function_exists('swoole_hook_flags')) { - return \is_resource($resource) || $resource instanceof \Swoole\Curl\Handler; - } - if (swoole_hook_flags() & SWOOLE_HOOK_CURL) { + if (Runtime::getHookFlags() & SWOOLE_HOOK_CURL) { return \is_resource($resource) || $resource instanceof \Swoole\Curl\Handler; } return \is_resource($resource); @@ -23,12 +22,11 @@ namespace Oss\OssClient { } namespace Oss\Http { + use Swoole\Runtime; + function is_resource($resource) { - if (! function_exists('swoole_hook_flags')) { - return \is_resource($resource) || $resource instanceof \Swoole\Curl\Handler; - } - if (swoole_hook_flags() & SWOOLE_HOOK_CURL) { + if (Runtime::getHookFlags() & SWOOLE_HOOK_CURL) { return \is_resource($resource) || $resource instanceof \Swoole\Curl\Handler; } return \is_resource($resource); diff --git a/src/utils/src/Functions.php b/src/utils/src/Functions.php index 72ac8172b..e0408ac41 100644 --- a/src/utils/src/Functions.php +++ b/src/utils/src/Functions.php @@ -439,11 +439,11 @@ if (! function_exists('run')) { if (! function_exists('swoole_hook_flags')) { /** - * Return the currently enabled swoole hook flags. + * Return the default swoole hook flags, you can rewrite it by defining `SWOOLE_HOOK_FLAGS`. */ function swoole_hook_flags(): int { - return \Swoole\Runtime::getHookFlags(); + return defined('SWOOLE_HOOK_FLAGS') ? SWOOLE_HOOK_FLAGS : SWOOLE_HOOK_ALL; } }