mirror of
https://github.com/predis/predis.git
synced 2026-08-29 11:41:29 +00:00
Use only one check for replies that should not be passed to a reply parser.
This commit is contained in:
+14
-4
@@ -697,6 +697,7 @@ class ResponseReader {
|
||||
}
|
||||
|
||||
class ResponseError {
|
||||
public $skipParse = true;
|
||||
private $_message;
|
||||
|
||||
public function __construct($message) {
|
||||
@@ -722,11 +723,21 @@ class ResponseError {
|
||||
}
|
||||
|
||||
class ResponseQueued {
|
||||
public $queued = true;
|
||||
public $skipParse = true;
|
||||
|
||||
public function __toString() {
|
||||
return Protocol::QUEUED;
|
||||
}
|
||||
|
||||
public function __get($property) {
|
||||
if ($property === 'queued') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function __isset($property) {
|
||||
return $property === 'queued';
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -873,7 +884,7 @@ class MultiExecBlock {
|
||||
}
|
||||
$command = $client->createCommand($method, $arguments);
|
||||
$response = $client->executeCommand($command);
|
||||
if (!isset($response->queued)) {
|
||||
if (!$response instanceof \Predis\ResponseQueued) {
|
||||
$this->malformedServerResponse(
|
||||
'The server did not respond with a QUEUED status reply'
|
||||
);
|
||||
@@ -1344,8 +1355,7 @@ class Connection implements IConnection {
|
||||
|
||||
public function readResponse(Command $command) {
|
||||
$response = $this->_reader->read($this);
|
||||
$skipparse = isset($response->queued) || isset($response->error);
|
||||
return $skipparse ? $response : $command->parseResponse($response);
|
||||
return isset($response->skipParse) ? $response : $command->parseResponse($response);
|
||||
}
|
||||
|
||||
public function executeCommand(Command $command) {
|
||||
|
||||
@@ -216,6 +216,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
|
||||
|
||||
function testResponseQueued() {
|
||||
$response = new \Predis\ResponseQueued();
|
||||
$this->assertTrue($response->skipParse);
|
||||
$this->assertTrue($response->queued);
|
||||
$this->assertEquals(\Predis\Protocol::QUEUED, (string)$response);
|
||||
}
|
||||
@@ -227,6 +228,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
|
||||
$errorMessage = 'ERROR MESSAGE';
|
||||
$response = new \Predis\ResponseError($errorMessage);
|
||||
|
||||
$this->assertTrue($response->skipParse);
|
||||
$this->assertTrue($response->error);
|
||||
$this->assertEquals($errorMessage, $response->message);
|
||||
$this->assertEquals($errorMessage, (string)$response);
|
||||
|
||||
Reference in New Issue
Block a user