Skip to content

Commit 4ce43bb

Browse files
committed
No longer use integers as adapter handles
1 parent da7a7c7 commit 4ce43bb

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/Client.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ public function delete($resource, $id, array $data = null)
300300
*/
301301
public function end($handle)
302302
{
303-
Util::throwIfNotType(['int' => [$handle]]);
304303
Util::ensure(true, array_key_exists($handle, $this->_handles), '\InvalidArgumentException', ['$handle not found']);
305304

306305
list($cachedResponse, $adapterHandle, $request) = $this->_handles[$handle];
@@ -434,14 +433,15 @@ private function _start($url, $method, $body = null, array $headers = [])
434433
if ($request->getMethod() === 'GET' && $this->_cacheMode & self::CACHE_MODE_GET) {
435434
$cached = $this->_cache->get($request);
436435
if ($cached !== null) {
437-
$this->_handles[] = [$cached, null, $request];
438-
end($this->_handles);
439-
return key($this->_handles);
436+
//The response is cache. Generate a key for the _handles array
437+
$key = uniqid();
438+
$this->_handles[$key] = [$cached, null, $request];
439+
return $key;
440440
}
441441
}
442442

443-
$this->_handles[] = [null, $this->_adapter->start($request), $request];
444-
end($this->_handles);
445-
return key($this->_handles);
443+
$key = $this->_adapter->start($request);
444+
$this->_handles[$key] = [null, $key, $request];
445+
return $key;
446446
}
447447
}

0 commit comments

Comments
 (0)