Skip to content

Commit

Permalink
Merge pull request #526 from huangzhhui/fix-getpcid
Browse files Browse the repository at this point in the history
If swoole method return false, transfer the result to null
  • Loading branch information
limingxinleo committed Sep 5, 2019
2 parents 9c885f4 + 3767894 commit ce5dfaa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
- [#482](https://github.com/hyperf-cloud/hyperf/pull/482) Re-generate the `fillable` argument of Model when use `refresh-fillable` option, at the same time, the command will keep the `fillable` argument as default behaviours.
- [#501](https://github.com/hyperf-cloud/hyperf/pull/501) When the path argument of Mapping annotation is an empty string, then the path is equal to prefix of Controller annotation.
- [#513](https://github.com/hyperf-cloud/hyperf/pull/513) Rewrite process name with `app_name`.
- [#526](https://github.com/hyperf-cloud/hyperf/pull/526) When execute `Hyperf\Utils\Coroutine::parentId()` static method in non-coroutine context will return null.

## Fixed

Expand Down
7 changes: 4 additions & 3 deletions src/utils/src/Coroutine.php
Expand Up @@ -42,15 +42,16 @@ public static function id(): int

/**
* Returns the parent coroutine ID.
* Returns -1 when running in non-coroutine context.
* Returns -1 when running in the top level coroutine.
* Returns null when running in non-coroutine context.
*
* @see https://github.com/swoole/swoole-src/pull/2669/files#diff-3bdf726b0ac53be7e274b60d59e6ec80R940
*/
public static function parentId(): int
public static function parentId(): ?int
{
$cid = SwooleCoroutine::getPcid();
if ($cid === false) {
return -1;
return null;
}

return $cid;
Expand Down

0 comments on commit ce5dfaa

Please sign in to comment.