Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit ebc5859

Browse files
authored
Merge pull request #483 from memfork/fix-could-not-working-task-when-enabling-task_enable_coroutine
fix could not working onTask when enabling task_enable_coroutine on swoole_http.php
2 parents f94b69f + c89542d commit ebc5859

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Server/Manager.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,19 @@ protected function resetOnRequest()
260260
*
261261
* @param mixed $server
262262
* @param string|\Swoole\Server\Task $taskId or $task
263-
* @param string $srcWorkerId
264-
* @param mixed $data
263+
* @param string|null $srcWorkerId
264+
* @param mixed|null $data
265265
*/
266-
public function onTask($server, $taskId, $srcWorkerId, $data)
266+
public function onTask($server, $task, $srcWorkerId = null, $data = null)
267267
{
268+
if ($task instanceof Task) {
269+
$data = $task->data;
270+
$srcWorkerId = $task->worker_id;
271+
$taskId = $task->id;
272+
} else {
273+
$taskId = $task;
274+
}
275+
268276
$this->container->make('events')->dispatch('swoole.task', func_get_args());
269277

270278
try {

0 commit comments

Comments
 (0)