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 d05f351..3dc643c 100644
--- a/lib/php/src/transport/TSocket.php
+++ b/lib/php/src/transport/TSocket.php
@@ -171,7 +171,7 @@
$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 @@
$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_);
}