mirror of
https://github.com/predis/predis.git
synced 2026-08-28 03:02:04 +00:00
Remove Predis\Network\IConnectionSingle::setProtocolOption() for now.
This commit is contained in:
@@ -27,7 +27,7 @@ class ComposableStreamConnection extends StreamConnection implements IConnection
|
||||
return $this->_protocol;
|
||||
}
|
||||
|
||||
public function setProtocolOption($option, $value) {
|
||||
protected function setProtocolOption($option, $value) {
|
||||
return $this->_protocol->setOption($option, $value);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ interface IConnectionSingle extends IConnection {
|
||||
public function __toString();
|
||||
public function getResource();
|
||||
public function getParameters();
|
||||
public function setProtocolOption($option, $value);
|
||||
public function pushInitCommand(ICommand $command);
|
||||
public function read();
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class PhpiredisConnection extends ConnectionBase {
|
||||
return parent::checkParameters($parameters);
|
||||
}
|
||||
|
||||
private function initializeReader() {
|
||||
private function initializeReader($throw_errors = true) {
|
||||
if (!function_exists('phpiredis_reader_create')) {
|
||||
throw new ClientException(
|
||||
'The phpiredis extension must be loaded in order to be able to ' .
|
||||
@@ -62,13 +62,12 @@ class PhpiredisConnection extends ConnectionBase {
|
||||
}
|
||||
$reader = phpiredis_reader_create();
|
||||
phpiredis_reader_set_status_handler($reader, $this->getStatusHandler());
|
||||
phpiredis_reader_set_error_handler($reader, $this->getErrorHandler());
|
||||
phpiredis_reader_set_error_handler($reader, $this->getErrorHandler($throw_errors));
|
||||
$this->_reader = $reader;
|
||||
}
|
||||
|
||||
protected function initializeProtocol(ConnectionParameters $parameters) {
|
||||
$this->initializeReader();
|
||||
$this->setProtocolOption('throw_errors', $parameters->throw_errors);
|
||||
$this->initializeReader($parameters->throw_errors);
|
||||
}
|
||||
|
||||
private function getStatusHandler() {
|
||||
@@ -259,17 +258,4 @@ class PhpiredisConnection extends ConnectionBase {
|
||||
$reply = $this->read();
|
||||
return isset($reply->skipParse) ? $reply : $command->parseResponse($reply);
|
||||
}
|
||||
|
||||
public function setProtocolOption($option, $value) {
|
||||
switch ($option) {
|
||||
case 'throw_errors':
|
||||
phpiredis_reader_set_error_handler(
|
||||
$this->_reader,
|
||||
$this->getErrorHandler((bool) $value)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$this->onInvalidOption($option, $this->getParameters());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ class StreamConnection extends ConnectionBase {
|
||||
return isset($reply->skipParse) ? $reply : $command->parseResponse($reply);
|
||||
}
|
||||
|
||||
public function setProtocolOption($option, $value) {
|
||||
protected function setProtocolOption($option, $value) {
|
||||
switch ($option) {
|
||||
case 'iterable_multibulk':
|
||||
$this->_mbiterable = (bool) $value;
|
||||
|
||||
@@ -450,9 +450,8 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
function testCommandPipeline_ServerExceptionInCallableBlock() {
|
||||
$client = RC::getConnection();
|
||||
$client = RC::createConnection(array('throw_errors' => false));
|
||||
$client->flushdb();
|
||||
$client->getConnection()->setProtocolOption('throw_errors', false);
|
||||
|
||||
$replies = $client->pipeline(function($pipe) {
|
||||
$pipe->set('foo', 'bar');
|
||||
@@ -572,9 +571,8 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
function testMultiExecContext_ServerExceptionInCallableBlock() {
|
||||
$client = RC::getConnection();
|
||||
$client = RC::createConnection(array('throw_errors' => false));
|
||||
$client->flushdb();
|
||||
$client->getConnection()->setProtocolOption('throw_errors', false);
|
||||
|
||||
$replies = $client->multiExec(function($multi) {
|
||||
$multi->set('foo', 'bar');
|
||||
|
||||
@@ -39,17 +39,17 @@ class RC {
|
||||
|
||||
private static $_connection;
|
||||
|
||||
public static function getConnectionArguments() {
|
||||
return array('host' => RC::SERVER_HOST, 'port' => RC::SERVER_PORT);
|
||||
public static function getConnectionArguments(Array $additional = array()) {
|
||||
return array_merge(array('host' => RC::SERVER_HOST, 'port' => RC::SERVER_PORT), $additional);
|
||||
}
|
||||
|
||||
public static function getConnectionParameters() {
|
||||
return new Predis\ConnectionParameters(array('host' => RC::SERVER_HOST, 'port' => RC::SERVER_PORT));
|
||||
public static function getConnectionParameters(Array $additional = array()) {
|
||||
return new Predis\ConnectionParameters(self::getConnectionArguments($additional));
|
||||
}
|
||||
|
||||
private static function createConnection() {
|
||||
public static function createConnection(Array $additional = array()) {
|
||||
$serverProfile = Predis\Profiles\ServerProfile::get(self::SERVER_VERSION);
|
||||
$connection = new Predis\Client(RC::getConnectionArguments(), $serverProfile);
|
||||
$connection = new Predis\Client(RC::getConnectionArguments($additional), $serverProfile);
|
||||
$connection->connect();
|
||||
$connection->select(RC::DEFAULT_DATABASE);
|
||||
return $connection;
|
||||
|
||||
Reference in New Issue
Block a user