amphp / redis

Efficient asynchronous communication with Redis servers, enabling scalable and responsive data storage and retrieval.

Home Page:https://amphp.org/redis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

1.x RemoteExecutor#143 Call to a member function fail() on null

Dhu-kmw opened this issue · comments

Hi,
Thanks for your handy library.
With the newest 1.x version we found a (possible) bug:

Call to a member function fail() on null
in /var/www/html/vendor/amphp/redis/src/RemoteExecutor.php at line 143

https://github.com/amphp/redis/blob/1.x/src/RemoteExecutor.php#L135C17-L145C18
introduced with
ed5555e

/*#135*/ } finally {
/*#136*/     $temp = $queue;
/*#137*/     $queue = [];
/*#138*/     $connect = null;
/*#139*/     $socket->close();
/*#140*/ 
/*#141*/     while ($temp) {
/*#142*/         $deferred = \array_shift($queue);
/*#143*/         $deferred->fail($error);
/*#144*/     }
/*#145*/ }

If I understand correctly:
$queue is emptied in #137, but the old reference is stored in $temp.
In the while-loop the array_shift call on (now empty) $queue will always return null.
I don't know the bigger picture with the $temp dereferencing, but only with the local context, I guess in #142 it should use $temp instead of $queue.