From 74050c46e743651f10009102aff5bf91b23f95d3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 25 Dec 2021 19:21:41 +0800 Subject: [PATCH] update to 2.6.4 (build 432) --- docs/component/bot/robot-api.md | 15 +++++ docs/guide/errcode.md | 1 + docs/update/build-update.md | 6 ++ docs/update/v2.md | 12 +++- src/ZM/API/CQAPI.php | 6 ++ src/ZM/API/GoCqhttpAPIV11.php | 111 ++++++++++++++++++++++++++++++++ src/ZM/API/OneBotV11.php | 111 ++++++++++++++++++-------------- src/ZM/ConsoleApplication.php | 2 +- src/ZM/Framework.php | 2 +- src/ZM/MySQL/MySQLWrapper.php | 2 +- 10 files changed, 215 insertions(+), 53 deletions(-) create mode 100644 src/ZM/API/GoCqhttpAPIV11.php diff --git a/docs/component/bot/robot-api.md b/docs/component/bot/robot-api.md index a0edf5db3..194456cf1 100644 --- a/docs/component/bot/robot-api.md +++ b/docs/component/bot/robot-api.md @@ -769,6 +769,21 @@ vardump($result["retcode"]); //如果成功撤回,输出 int(0) 响应数据:无 +### getExtendedAPI() + +用来调用 OneBot 标准之外扩展出来的自定义 API。与下方 `callExtendedAPI` 不同的是,为了方便用户使用,炸毛框架内置了热门使用并且相对稳定的机器人客户端的专有 API。 + +目前内置了 `go-cqhttp` 频道相关的扩充 API。 + +使用示例:`getExtendedAPI('go-cqhttp')->getGuildList()` +使用示例2:`getExtendedAPI()->sendGuildChannelMsg($guild_id, $channel_id, '频道的消息')` + +唯一一个参数做保留,用于选择不同客户端,目前仅支持 `go-cqhttp`,所以缺省也默认为 `go-cqhttp`。 + +!!! warning "注意" + + 由于不同版本的扩展 API 变化可能会很大,改动较多,炸毛框架不会将对应扩展方法写入文档,具体调用情况可根据 IDE 自动补全中的文档或对应类的注释查看。 + ### callExtendedAPI() (扩充 API) 用来调用 OneBot 标准之外扩展出来的自定义 API。 diff --git a/docs/guide/errcode.md b/docs/guide/errcode.md index de1f46bb7..6c06344cd 100644 --- a/docs/guide/errcode.md +++ b/docs/guide/errcode.md @@ -70,5 +70,6 @@ | E00068 | 模块解包时无法正常拷贝文件 | 检查文件夹是否正常可以创建和写入。 | | E00069 | 框架不能启动两个 ConsoleApplication 实例 | 不要重复使用 `new ConsoleApplication()`。 | | E00070 | 框架找不到 `zm_data` 目录 | 检查配置中指定的 `zm_data` 目录是否存在。 | +| E00071 | 框架找不到对应类型的 API 调用类 | 检查 `getExtendedAPI($name)` 传入的 `$name` 是否正确 | | E99999 | 未知错误 | | diff --git a/docs/update/build-update.md b/docs/update/build-update.md index 9ec1ef993..621e7b627 100644 --- a/docs/update/build-update.md +++ b/docs/update/build-update.md @@ -4,6 +4,12 @@ 同时此处将只使用 build 版本号进行区分。 +## build 432 (2021-12-25) + +- 新增 GoCqhttpAPI 包,用于支持额外的 OneBot Action(API) +- 修复 MySQL 查询器中 `fetchOne()` 方法无法正确返回值的 Bug +- 修复 Swoole Hook 因配置不当无法正确使用的 Bug + ## build 431 (2021-12-22) - 修复 Issue #50 diff --git a/docs/update/v2.md b/docs/update/v2.md index 35c3b0729..6c6f9928e 100644 --- a/docs/update/v2.md +++ b/docs/update/v2.md @@ -1,6 +1,16 @@ # 更新日志(v2 版本) -# v2.6.3 (build 430) +## v2.6.4(build 432) + +> 更新时间:2021.12.25 + +- 新增 GoCqhttpAPI 包,用于支持额外的 OneBot Action(API) +- 修复 MySQL 查询器中 `fetchOne()` 方法无法正确返回值的 Bug +- 修复 Swoole Hook 因配置不当无法正确使用的 Bug +- 修复 Issue #50 +- 新增 PhpStorm IDE 直接运行框架的脚本 + +## v2.6.3 (build 430) > 更新时间:2021.12.8 diff --git a/src/ZM/API/CQAPI.php b/src/ZM/API/CQAPI.php index 2b24d55ed..76c9ae65c 100644 --- a/src/ZM/API/CQAPI.php +++ b/src/ZM/API/CQAPI.php @@ -80,6 +80,12 @@ private function processHttpAPI($connection, $reply, $function = null): bool { return false; } + public function getActionName($suffix, string $method) { + $postfix = ($suffix == OneBotV11::API_ASYNC ? '_async' : ($suffix == OneBotV11::API_RATE_LIMITED ? '_rate_limited' : '')); + $func_name = strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $method)); + return $func_name . $postfix; + } + public function __call($name, $arguments) { return false; } diff --git a/src/ZM/API/GoCqhttpAPIV11.php b/src/ZM/API/GoCqhttpAPIV11.php new file mode 100644 index 000000000..c1d9376e6 --- /dev/null +++ b/src/ZM/API/GoCqhttpAPIV11.php @@ -0,0 +1,111 @@ +connection = $connection; + $this->callback = $callback; + $this->prefix = $prefix; + } + + /** + * 获取频道系统内BOT的资料 + * 响应字段:nickname, tiny_id, avatar_url + * @link https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E7%B3%BB%E7%BB%9F%E5%86%85bot%E7%9A%84%E8%B5%84%E6%96%99 + * @return array|bool + */ + public function getGuildServiceProfile() + { + return $this->processAPI($this->connection, [ + 'action' => $this->getActionName($this->prefix, __FUNCTION__) + ], $this->callback); + } + + /** + * 获取频道列表 + * @link https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E5%88%97%E8%A1%A8 + * @return array|bool + */ + public function getGuildList() { + return $this->processAPI($this->connection, [ + 'action' => $this->getActionName($this->prefix, __FUNCTION__) + ], $this->callback); + } + + /** + * 通过访客获取频道元数据 + * @link https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E9%80%9A%E8%BF%87%E8%AE%BF%E5%AE%A2%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E5%85%83%E6%95%B0%E6%8D%AE + * @param $guild_id + * @return array|bool + */ + public function getGuildMetaByGuest($guild_id) { + return $this->processAPI($this->connection, [ + 'action' => $this->getActionName($this->prefix, __FUNCTION__), + 'params' => [ + 'guild_id' => $guild_id + ] + ], $this->callback); + } + + /** + * 获取子频道列表 + * @link https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E8%8E%B7%E5%8F%96%E5%AD%90%E9%A2%91%E9%81%93%E5%88%97%E8%A1%A8 + * @param $guild_id + * @param false $no_cache + * @return array|bool + */ + public function getGuildChannelList($guild_id, bool $no_cache = false) { + return $this->processAPI($this->connection, [ + 'action' => $this->getActionName($this->prefix, __FUNCTION__), + 'params' => [ + 'guild_id' => $guild_id, + 'no_cache' => $no_cache + ] + ], $this->callback); + } + + /** + * 获取频道成员列表 + * @link https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8 + * @param $guild_id + * @return array|bool + */ + public function getGuildMembers($guild_id) { + return $this->processAPI($this->connection, [ + 'action' => $this->getActionName($this->prefix, __FUNCTION__), + 'params' => [ + 'guild_id' => $guild_id + ] + ], $this->callback); + } + + /** + * 发送信息到子频道 + * @link https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E5%8F%91%E9%80%81%E4%BF%A1%E6%81%AF%E5%88%B0%E5%AD%90%E9%A2%91%E9%81%93 + * @param $guild_id + * @param $channel_id + * @param $message + * @return array|bool + */ + public function sendGuildChannelMsg($guild_id, $channel_id, $message) { + return $this->processAPI($this->connection, [ + 'action' => $this->getActionName($this->prefix, __FUNCTION__), + 'params' => [ + 'guild_id' => $guild_id, + 'channel_id' => $channel_id, + 'message' => $message + ] + ], $this->callback); + } +} diff --git a/src/ZM/API/OneBotV11.php b/src/ZM/API/OneBotV11.php index 6703f26bd..2d87ca761 100644 --- a/src/ZM/API/OneBotV11.php +++ b/src/ZM/API/OneBotV11.php @@ -1,4 +1,4 @@ -processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'user_id' => $user_id, 'message' => $message, @@ -111,7 +112,7 @@ public function sendPrivateMsg($user_id, $message, $auto_escape = false) { */ public function sendGroupMsg($group_id, $message, $auto_escape = false) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, 'message' => $message, @@ -131,7 +132,7 @@ public function sendGroupMsg($group_id, $message, $auto_escape = false) { */ public function sendMsg($message_type, $target_id, $message, $auto_escape = false) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'message_type' => $message_type, ($message_type == 'private' ? 'user' : $message_type) . '_id' => $target_id, @@ -149,7 +150,7 @@ public function sendMsg($message_type, $target_id, $message, $auto_escape = fals */ public function deleteMsg($message_id) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'message_id' => $message_id ] @@ -164,7 +165,7 @@ public function deleteMsg($message_id) { */ public function getMsg($message_id) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'message_id' => $message_id ] @@ -179,7 +180,7 @@ public function getMsg($message_id) { */ public function getForwardMsg($id) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'id' => $id ] @@ -195,7 +196,7 @@ public function getForwardMsg($id) { */ public function sendLike($user_id, $times = 1) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'user_id' => $user_id, 'times' => $times @@ -213,7 +214,7 @@ public function sendLike($user_id, $times = 1) { */ public function setGroupKick($group_id, $user_id, $reject_add_request = false) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, 'user_id' => $user_id, @@ -232,7 +233,7 @@ public function setGroupKick($group_id, $user_id, $reject_add_request = false) { */ public function setGroupBan($group_id, $user_id, $duration = 1800) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, 'user_id' => $user_id, @@ -251,7 +252,7 @@ public function setGroupBan($group_id, $user_id, $duration = 1800) { */ public function setGroupAnonymousBan($group_id, $anonymous_or_flag, $duration = 1800) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, (is_string($anonymous_or_flag) ? 'flag' : 'anonymous') => $anonymous_or_flag, @@ -269,7 +270,7 @@ public function setGroupAnonymousBan($group_id, $anonymous_or_flag, $duration = */ public function setGroupWholeBan($group_id, $enable = true) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, 'enable' => $enable @@ -287,7 +288,7 @@ public function setGroupWholeBan($group_id, $enable = true) { */ public function setGroupAdmin($group_id, $user_id, $enable = true) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, 'user_id' => $user_id, @@ -305,7 +306,7 @@ public function setGroupAdmin($group_id, $user_id, $enable = true) { */ public function setGroupAnonymous($group_id, $enable = true) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, 'enable' => $enable @@ -323,7 +324,7 @@ public function setGroupAnonymous($group_id, $enable = true) { */ public function setGroupCard($group_id, $user_id, $card = "") { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, 'user_id' => $user_id, @@ -341,7 +342,7 @@ public function setGroupCard($group_id, $user_id, $card = "") { */ public function setGroupName($group_id, $group_name) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, 'group_name' => $group_name @@ -358,7 +359,7 @@ public function setGroupName($group_id, $group_name) { */ public function setGroupLeave($group_id, $is_dismiss = false) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, 'is_dismiss' => $is_dismiss @@ -377,7 +378,7 @@ public function setGroupLeave($group_id, $is_dismiss = false) { */ public function setGroupSpecialTitle($group_id, $user_id, $special_title = "", $duration = -1) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, 'user_id' => $user_id, @@ -397,7 +398,7 @@ public function setGroupSpecialTitle($group_id, $user_id, $special_title = "", $ */ public function setFriendAddRequest($flag, $approve = true, $remark = "") { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'flag' => $flag, 'approve' => $approve, @@ -417,7 +418,7 @@ public function setFriendAddRequest($flag, $approve = true, $remark = "") { */ public function setGroupAddRequest($flag, $sub_type, $approve = true, $reason = "") { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'flag' => $flag, 'sub_type' => $sub_type, @@ -433,7 +434,7 @@ public function setGroupAddRequest($flag, $sub_type, $approve = true, $reason = * @return array|bool|null */ public function getLoginInfo() { - return $this->processAPI($this->connection, ['action' => $this->getActionName(__FUNCTION__)], $this->callback); + return $this->processAPI($this->connection, ['action' => $this->getActionName($this->prefix, __FUNCTION__)], $this->callback); } /** @@ -443,9 +444,9 @@ public function getLoginInfo() { * @param bool $no_cache * @return array|bool|null */ - public function getStrangerInfo($user_id, $no_cache = false) { + public function getStrangerInfo($user_id, bool $no_cache) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'user_id' => $user_id, 'no_cache' => $no_cache @@ -460,7 +461,7 @@ public function getStrangerInfo($user_id, $no_cache = false) { */ public function getFriendList() { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__) + 'action' => $this->getActionName($this->prefix, __FUNCTION__) ], $this->callback); } @@ -473,7 +474,7 @@ public function getFriendList() { */ public function getGroupInfo($group_id, $no_cache = false) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, 'no_cache' => $no_cache @@ -488,7 +489,7 @@ public function getGroupInfo($group_id, $no_cache = false) { */ public function getGroupList() { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__) + 'action' => $this->getActionName($this->prefix, __FUNCTION__) ], $this->callback); } @@ -500,9 +501,9 @@ public function getGroupList() { * @param bool $no_cache * @return array|bool|null */ - public function getGroupMemberInfo($group_id, $user_id, $no_cache = false) { + public function getGroupMemberInfo($group_id, $user_id, bool $no_cache) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, 'user_id' => $user_id, @@ -519,7 +520,7 @@ public function getGroupMemberInfo($group_id, $user_id, $no_cache = false) { */ public function getGroupMemberList($group_id) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id ] @@ -535,7 +536,7 @@ public function getGroupMemberList($group_id) { */ public function getGroupHonorInfo($group_id, $type) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'group_id' => $group_id, 'type' => $type @@ -550,7 +551,7 @@ public function getGroupHonorInfo($group_id, $type) { */ public function getCsrfToken() { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__) + 'action' => $this->getActionName($this->prefix, __FUNCTION__) ], $this->callback); } @@ -562,7 +563,7 @@ public function getCsrfToken() { */ public function getCredentials($domain = "") { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'domain' => $domain ] @@ -578,7 +579,7 @@ public function getCredentials($domain = "") { */ public function getRecord($file, $out_format) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'file' => $file, 'out_format' => $out_format @@ -594,7 +595,7 @@ public function getRecord($file, $out_format) { */ public function getImage($file) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'file' => $file ] @@ -608,7 +609,7 @@ public function getImage($file) { */ public function canSendImage() { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__) + 'action' => $this->getActionName($this->prefix, __FUNCTION__) ], $this->callback); } @@ -619,7 +620,7 @@ public function canSendImage() { */ public function canSendRecord() { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__) + 'action' => $this->getActionName($this->prefix, __FUNCTION__) ], $this->callback); } @@ -630,7 +631,7 @@ public function canSendRecord() { */ public function getStatus() { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__) + 'action' => $this->getActionName($this->prefix, __FUNCTION__) ], $this->callback); } @@ -641,7 +642,7 @@ public function getStatus() { */ public function getVersionInfo() { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__) + 'action' => $this->getActionName($this->prefix, __FUNCTION__) ], $this->callback); } @@ -653,7 +654,7 @@ public function getVersionInfo() { */ public function setRestart($delay = 0) { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__), + 'action' => $this->getActionName($this->prefix, __FUNCTION__), 'params' => [ 'delay' => $delay ] @@ -667,20 +668,32 @@ public function setRestart($delay = 0) { */ public function cleanCache() { return $this->processAPI($this->connection, [ - 'action' => $this->getActionName(__FUNCTION__) + 'action' => $this->getActionName($this->prefix, __FUNCTION__) ], $this->callback); } + /** + * 获取内置支持的扩展API对象 + * 现支持 go-cqhttp 的扩展API + * @param string $package_name + * @return mixed + * @throws ZMKnownException + */ + public function getExtendedAPI(string $package_name = 'go-cqhttp') { + $table = [ + 'go-cqhttp' => GoCqhttpAPIV11::class, + ]; + if (isset($table[$package_name])) { + return new $table[$package_name]($this->connection, $this->callback, $this->prefix); + } else { + throw new ZMKnownException(zm_internal_errcode('E00071'), '无法找到对应的调用扩展类'); + } + } + public function callExtendedAPI($action, $params = []) { return $this->processAPI($this->connection, [ 'action' => $action, 'params' => $params ], $this->callback); } - - private function getActionName(string $method) { - $prefix = ($this->prefix == self::API_ASYNC ? '_async' : ($this->prefix == self::API_RATE_LIMITED ? '_rate_limited' : '')); - $func_name = strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $method)); - return $func_name . $prefix; - } } \ No newline at end of file diff --git a/src/ZM/ConsoleApplication.php b/src/ZM/ConsoleApplication.php index 93fa732a2..36017527f 100644 --- a/src/ZM/ConsoleApplication.php +++ b/src/ZM/ConsoleApplication.php @@ -30,7 +30,7 @@ class ConsoleApplication extends Application { private static $obj = null; - const VERSION_ID = 431; + const VERSION_ID = 432; const VERSION = "2.6.4"; /** diff --git a/src/ZM/Framework.php b/src/ZM/Framework.php index fe3a471b2..06e678e09 100644 --- a/src/ZM/Framework.php +++ b/src/ZM/Framework.php @@ -487,7 +487,7 @@ private function parseCliArgs($args, &$add_port) { } } $global_hook = ZMConfig::get("global", 'runtime')['swoole_coroutine_hook_flags'] ?? (SWOOLE_HOOK_ALL & (~SWOOLE_HOOK_CURL)); - if ($coroutine_mode && $global_hook === false) Runtime::enableCoroutine(true, $global_hook); + if ($coroutine_mode) Runtime::enableCoroutine(true, $global_hook); else Runtime::enableCoroutine(false, SWOOLE_HOOK_ALL); } diff --git a/src/ZM/MySQL/MySQLWrapper.php b/src/ZM/MySQL/MySQLWrapper.php index d40a1d4ec..a5fd1d7c8 100644 --- a/src/ZM/MySQL/MySQLWrapper.php +++ b/src/ZM/MySQL/MySQLWrapper.php @@ -94,7 +94,7 @@ public function fetchNumeric(string $query, array $params = [], array $types = [ * @return false|mixed * @throws DbException */ - public function fetchOne(string $query, array $params = [], array $types = []): bool { + public function fetchOne(string $query, array $params = [], array $types = []) { try { return $this->connection->fetchOne($query, $params, $types); } catch (Throwable $e) {