From 0c102f52c32417067a19f142f85ddfa7ae7d8878 Mon Sep 17 00:00:00 2001 From: Pedro Camacho Date: Wed, 22 Oct 2014 12:00:33 +0100 Subject: [PATCH] method _bulk_reply is not returning the correct data Redis protocol sends a "CRLF" when it returns a string with zero length ($0), but when it returns a string "-1" ($-1) length it does not have a "CRLF". Solution is to remove "CRLF" when its a zero length string. --- libraries/Redis.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/Redis.php b/libraries/Redis.php index 1e4c389..6bc12b2 100644 --- a/libraries/Redis.php +++ b/libraries/Redis.php @@ -322,7 +322,12 @@ private function _bulk_reply() // fully return from redis and enter into socket. $value_length = (int) fgets($this->_connection); - if ($value_length <= 0) return NULL; + if ($value_length <= 0) { + if ($value_length == 0) { + fgets($this->_connection); + } + return NULL; + } $response = ''; @@ -511,4 +516,4 @@ function __destruct() { if ($this->_connection) fclose($this->_connection); } -} \ No newline at end of file +}