Add (int) case to Thrift version comparison
Summary: Deals with 32 bit machines doing a weird sign-bit thing here.
Reviewed By: dreiss
Test Plan: For 32 bit AmieStreet partners
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665356 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/php/src/protocol/TBinaryProtocol.php b/lib/php/src/protocol/TBinaryProtocol.php
index 63b10bf..f66f8ee 100644
--- a/lib/php/src/protocol/TBinaryProtocol.php
+++ b/lib/php/src/protocol/TBinaryProtocol.php
@@ -40,7 +40,7 @@
$this->writeString($name) +
$this->writeI32($seqid);
} else {
- return
+ return
$this->writeString($name) +
$this->writeByte($type) +
$this->writeI32($seqid);
@@ -183,8 +183,8 @@
public function readMessageBegin(&$name, &$type, &$seqid) {
$result = $this->readI32($sz);
if ($sz < 0) {
- $version = $sz & self::VERSION_MASK;
- if ($version != self::VERSION_1) {
+ $version = (int) ($sz & self::VERSION_MASK);
+ if ($version != (int) self::VERSION_1) {
throw new TProtocolException('Bad version identifier: '.$sz, TProtocolException::BAD_VERSION);
}
$type = $sz & 0x000000ff;
@@ -197,7 +197,7 @@
} else {
// Handle pre-versioned input
$name = $this->trans_->readAll($sz);
- $result +=
+ $result +=
$sz +
$this->readByte($type) +
$this->readI32($seqid);
@@ -311,7 +311,7 @@
$hi = $arr[1];
$lo = $arr[2];
$isNeg = $hi < 0;
-
+
// Check for a negative
if ($isNeg) {
$hi = ~$hi & (int)0xffffffff;
@@ -327,17 +327,17 @@
// Force 32bit words in excess of 2G to pe positive - we deal wigh sign
// explicitly below
-
+
if ($hi & (int)0x80000000) {
$hi &= (int)0x7fffffff;
$hi += 0x80000000;
}
-
+
if ($lo & (int)0x80000000) {
$lo &= (int)0x7fffffff;
$lo += 0x80000000;
}
-
+
$value = $hi * 4294967296 + $lo;
if ($isNeg) {
@@ -360,7 +360,7 @@
$value = $arr[1]*4294967296 + $arr[2];
}
}
-
+
return 8;
}
@@ -392,7 +392,7 @@
public function __construct($strictRead=false, $strictWrite=false) {
$this->strictRead_ = $strictRead;
$this->strictWrite_ = $strictWrite;
- }
+ }
public function getProtocol($trans) {
return new TBinaryProtocol($trans, $this->strictRead, $this->strictWrite);
@@ -409,7 +409,7 @@
// TBufferedTransport (which does)
if (!method_exists($trans, 'putBack')) {
$trans = new TBufferedTransport($trans);
- }
+ }
parent::__construct($trans, $strictRead, $strictWrite);
}
}