Use only one check for replies that should not be passed to a reply parser.

This commit is contained in:
Daniele Alessandri
2011-01-14 17:07:00 +01:00
parent 8dcd10dbbc
commit 118af2809c
2 changed files with 16 additions and 4 deletions
+14 -4
View File
@@ -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) {
+2
View File
@@ -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);