Sfoglia il codice sorgente

Do not assume that the position of a MultiBulkResponse iterator is 0.

Daniele Alessandri 13 anni fa
parent
commit
6ba1890da9

+ 10 - 0
lib/Predis/Iterators/MultiBulkResponse.php

@@ -81,6 +81,16 @@ abstract class MultiBulkResponse implements \Iterator, \Countable
         return $this->replySize;
     }
 
+    /**
+     * Returns the current position of the iterator.
+     *
+     * @return int
+     */
+    public function getPosition()
+    {
+        return $this->position;
+    }
+
     /**
      * {@inheritdoc}
      */

+ 1 - 1
lib/Predis/Iterators/MultiBulkResponseTuple.php

@@ -28,7 +28,7 @@ class MultiBulkResponseTuple extends MultiBulkResponse implements \OuterIterator
     {
         $virtualSize = count($iterator) / 2;
         $this->iterator = $iterator;
-        $this->position = 0;
+        $this->position = $iterator->getPosition();
         $this->current = $virtualSize > 0 ? $this->getValue() : null;
         $this->replySize = $virtualSize;
     }