diff --git a/src/Client.php b/src/Client.php index 1cd1ffb..6078ca5 100644 --- a/src/Client.php +++ b/src/Client.php @@ -355,11 +355,12 @@ protected function submitTask(Task $task) $s = $this->getConnection(); Connection::send($s, $type, $params); - if (!is_array(Connection::$waiting[spl_object_id($s)])) { - Connection::$waiting[spl_object_id($s)] = []; + $key = is_object($s) ? spl_object_id($s) : intval($s); + if (!is_array(Connection::$waiting[$key])) { + Connection::$waiting[$key] = []; } - Connection::$waiting[spl_object_id($s)][] = $task; + Connection::$waiting[$key][] = $task; } /** @@ -463,7 +464,8 @@ protected function handleResponse($resp, $s, Set $tasks) $task->fail(); break; case 'job_created': - $task = array_shift(Connection::$waiting[spl_object_id($s)]); + $key = is_object($s) ? spl_object_id($s) : intval($s); + $task = array_shift(Connection::$waiting[$key]); $task->handle = $resp['data']['handle']; if ($task->type == Task::JOB_BACKGROUND) { $task->finished = true; diff --git a/src/Connection.php b/src/Connection.php index f8062f3..de97a94 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -174,7 +174,8 @@ public static function connect($host = 'localhost', $timeout = 2000) ); } - self::$waiting[spl_object_id($socket)] = []; + $key = is_object($socket) ? spl_object_id($socket) : intval($socket); + self::$waiting[$key] = []; return $socket; } @@ -371,7 +372,7 @@ public static function close($socket) */ public static function isConnected($socket) { - return $conn !== false; + return $socket !== false; } /**