Fixed PHP to support field numbers >=2**28. (#8235)

pull/8236/head
Joshua Haberman 4 years ago committed by GitHub
parent f6da785731
commit d5079ed7db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2076
      php/ext/google/protobuf/php-upb.c
  2. 875
      php/ext/google/protobuf/php-upb.h
  3. 4
      php/src/Google/Protobuf/Internal/GPBWire.php
  4. 10
      php/tests/EncodeDecodeTest.php
  5. 4
      php/tests/proto/test.proto

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -50,8 +50,8 @@ class GPBWire
public static function getTagFieldNumber($tag)
{
return ($tag >> self::TAG_TYPE_BITS) &
(1 << ((PHP_INT_SIZE * 8) - self::TAG_TYPE_BITS)) - 1;
// We have to mask because PHP has no arithmetic shift.
return ($tag >> self::TAG_TYPE_BITS) & 0x1fffffff;
}
public static function getTagWireType($tag)

@ -14,6 +14,7 @@ use Foo\TestStringValue;
use Foo\TestBytesValue;
use Foo\TestAny;
use Foo\TestEnum;
use Foo\TestLargeFieldNumber;
use Foo\TestMessage;
use Foo\TestMessage\Sub;
use Foo\TestPackedMessage;
@ -529,6 +530,15 @@ class EncodeDecodeTest extends TestBase
$this->assertSame("", $data);
}
public function testLargeFieldNumber()
{
$m = new TestLargeFieldNumber(['large_field_number' => 5]);
$data = $m->serializeToString();
$m2 = new TestLargeFieldNumber();
$m2->mergeFromString($data);
$this->assertSame(5, $m2->getLargeFieldNumber());
}
public function testDecodeInvalidInt32()
{
$this->expectException(Exception::class);

@ -220,6 +220,10 @@ message TestRandomFieldOrder {
string tag14 = 160;
}
message TestLargeFieldNumber {
int32 large_field_number = 536870911;
}
message TestReverseFieldOrder {
repeated int32 a = 2;
string b = 1;

Loading…
Cancel
Save