From 92026de281707eb9baeccc1bd5425066d11c2e55 Mon Sep 17 00:00:00 2001 From: Evan Johnson Date: Wed, 15 Jan 2014 16:36:13 -0700 Subject: [PATCH] Fix to consume loop to prevent passing empty statuses to enqueueStatus(), which was happening occasionally when for some reason the buffer would hold two "\r\n\r\n" sequences. --- lib/Phirehose.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Phirehose.php b/lib/Phirehose.php index f26b16b..4b37a17 100644 --- a/lib/Phirehose.php +++ b/lib/Phirehose.php @@ -464,6 +464,10 @@ public function consume($reconnect = TRUE) //Process each full tweet inside $this->buff while(1){ $eol = strpos($this->buff,"\r\n"); //Find next line ending + if($eol===0) { // if 0, then buffer starts with "\r\n", so trim it and loop again + $this->buff = substr($this->buff,$eol+2); // remove the "\r\n" from line start + continue; // loop again + } if($eol===false)break; //Time to get more data $enqueueStart = microtime(TRUE); $this->enqueueStatus(substr($this->buff,0,$eol));