Skip to content

Commit a15bc4e

Browse files
Fixing large string issue
`fread()` returns *up to* the `$length` specified, so this fixes an issue where `$length` bytes aren't present in the stream at the time of reading, leaving stray data for the next read to pick up.
1 parent 868727c commit a15bc4e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/RedisClient/Connection/StreamConnection.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ public function readLine() {
8787
* @return string
8888
*/
8989
public function read($length) {
90-
return fread($this->getResource(), $length);
90+
$read = 0;
91+
$data = '';
92+
while ($read != $length) {
93+
$data .= fread($this->getResource(), ($length - $read));
94+
$read = strlen($data);
95+
}
96+
return $data;
9197
}
9298

9399
}

0 commit comments

Comments
 (0)