Преглед на файлове

Do not implicitly set multibulk replies on composable connections.

This should be done externally on the underlying protocol instance.
Daniele Alessandri преди 12 години
родител
ревизия
fbcfdc343e
променени са 2 файла, в които са добавени 4 реда и са изтрити 7 реда
  1. 2 6
      lib/Predis/Connection/ComposableStreamConnection.php
  2. 2 1
      tests/Predis/Connection/ComposableStreamConnectionTest.php

+ 2 - 6
lib/Predis/Connection/ComposableStreamConnection.php

@@ -31,12 +31,8 @@ class ComposableStreamConnection extends StreamConnection implements ComposableC
      */
     public function __construct(ConnectionParametersInterface $parameters, ProtocolInterface $protocol = null)
     {
-        $protocol = $protocol ?: new TextProtocol();
-        $protocol->setOption('iterable_multibulk', $parameters->iterable_multibulk);
-
-        $this->mbiterable = null;
-        $this->protocol = $protocol;
         $this->parameters = $this->checkParameters($parameters);
+        $this->protocol = $protocol ?: new TextProtocol();
     }
 
     /**
@@ -134,6 +130,6 @@ class ComposableStreamConnection extends StreamConnection implements ComposableC
      */
     public function __sleep()
     {
-        return array_merge(parent::__sleep(), array('protocol'));
+        return array_diff(array_merge(parent::__sleep(), array('protocol')), array('mbiterable'));
     }
 }

+ 2 - 1
tests/Predis/Connection/ComposableStreamConnectionTest.php

@@ -74,7 +74,8 @@ class ComposableStreamConnectionTest extends ConnectionTestCase
      */
     public function testReadsMultibulkRepliesAsIterators()
     {
-        $connection = $this->getConnection($profile, true, array('iterable_multibulk' => true));
+        $connection = $this->getConnection($profile, true);
+        $connection->getProtocol()->setOption('iterable_multibulk', true);
 
         $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol')));
         $connection->writeCommand($profile->createCommand('lrange', array('metavars', 0, -1)));