RESP simple strings parsing always returns Status object response
Describe the bug
Right now, on StreamConnection while parsing RESP all simple strings are wrapped into Status object that represents status responses from commands (e.g OK, NOKEY, PONG, QUEUE etc.). But simple strings are used for many other responses not related with status (f.e FT.INFO command returns data as array of simple strings). Since, we have responses not related to any Status, I consider this as a bug.
Expected behavior
It's necessary to check if response is one of the "status" responses and return status object only in this case. Since, now we have a configuration layer represented by ClientConfiguration object, I suggest to put all possible response statuses there and check against them during parsing.
StreamConnection.php
/**
* {@inheritdoc}
*/
public function read()
{
$socket = $this->getResource();
$chunk = fgets($socket);
if ($chunk === false || $chunk === '') {
$this->onConnectionError('Error while reading line from the server.');
}
$prefix = $chunk[0];
$payload = substr($chunk, 1, -2);
switch ($prefix) {
case '+':
$responseStatuses = ClientConfiguration::getCommands()['responseStatuses'];
if(in_array($payload, $responseStatuses)) {
return StatusResponse::get($payload);
}
return $payload;Versions:
- Predis: [2.1.1]
- PHP [7.2]
- Redis Server [6.2.0]
- OS [MacOS 11.6.7]
Source: predis/predis