From: Mark Slee Date: Tue, 21 Nov 2006 02:01:22 +0000 (+0000) Subject: Thrift: Fix PHP socket fread return X-Git-Tag: 0.2.0~1594 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=e598d075f55af8db87ff1963c330e9ca7cc95b9e;p=common%2Fthrift.git Thrift: Fix PHP socket fread return Summary: If you read the string "0" then it treats that as false, so we have to check for both === false and === '' manually. Reviewed By: martin Notes: I hate php git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664878 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/php/src/transport/TSocket.php b/lib/php/src/transport/TSocket.php index d05f3517..3dc643ca 100644 --- a/lib/php/src/transport/TSocket.php +++ b/lib/php/src/transport/TSocket.php @@ -171,7 +171,7 @@ class TSocket extends TTransport { $pre = null; while (TRUE) { $buf = @fread($this->handle_, $len); - if (!$buf) { + if ($buf === FALSE || $buf === '') { throw new Exception('TSocket: Could not read '.$len.' bytes from '. $this->host_.':'.$this->port_); } else if (($sz = strlen($buf)) < $len) { @@ -201,7 +201,7 @@ class TSocket extends TTransport { $this->sendTimeoutSet_ = FALSE; } $data = @fread($this->handle_, $len); - if (!$data) { + if ($data === FALSE || $data === '') { throw new Exception('TSocket: Could not read '.$len.' bytes from '. $this->host_.':'.$this->port_); }