From e6356050037e35f5e1bbcfecd99e51c2c29fa65e Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 24 May 2021 11:15:46 -0700 Subject: [PATCH 01/18] Added missing release notes for 3.17.1. (#8649) --- CHANGES.txt | 2 ++ php/ext/google/protobuf/package.xml | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 0713945939961..395f2088b6887 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,9 +1,11 @@ 2021-05-07 version 3.17.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) PHP + * Fixed PHP memory leaks and arginfo errors. (#8614) * Fixed JSON parser to allow multiple values from the same oneof as long as all but one are null. Ruby + * Fixed memory bug: properly root repeated/map field when assigning. (#8639) * Fixed JSON parser to allow multiple values from the same oneof as long as all but one are null. diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index 4dbd351e5b180..829d7c9a6e8b8 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -22,7 +22,9 @@ 3-Clause BSD License - No new changes in 3.17.0 + * Fixed PHP memory leaks and arginfo errors. (#8614) + * Fixed JSON parser to allow multiple values from the same oneof as long as + all but one are null. @@ -975,6 +977,9 @@ G A release. 3-Clause BSD License + * Fixed PHP memory leaks and arginfo errors. (#8614) + * Fixed JSON parser to allow multiple values from the same oneof as long as + all but one are null. From eb3ab8c59eaf4d2b652e2c2cb50ef9679feee93a Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Fri, 14 May 2021 22:58:57 +0000 Subject: [PATCH 02/18] Add headerfiles to Makefile --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.am b/src/Makefile.am index 12eb70743bbbd..9121a177a3495 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -100,6 +100,7 @@ nobase_include_HEADERS = \ google/protobuf/generated_enum_util.h \ google/protobuf/generated_message_reflection.h \ google/protobuf/generated_message_table_driven.h \ + google/protobuf/generated_message_tctable_impl.h \ google/protobuf/generated_message_util.h \ google/protobuf/has_bits.h \ google/protobuf/implicit_weak_message.h \ From f9a60fc8ae0646377fd30d2490d7a8f6045b6754 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Fri, 14 May 2021 23:08:04 +0000 Subject: [PATCH 03/18] Add another header to Makefile --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.am b/src/Makefile.am index 9121a177a3495..ddf1e85f24a39 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -100,6 +100,7 @@ nobase_include_HEADERS = \ google/protobuf/generated_enum_util.h \ google/protobuf/generated_message_reflection.h \ google/protobuf/generated_message_table_driven.h \ + google/protobuf/generated_message_tctable_decl.h \ google/protobuf/generated_message_tctable_impl.h \ google/protobuf/generated_message_util.h \ google/protobuf/has_bits.h \ From 76bd17ca5b75486072acf36467b8b0e34555f11e Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Fri, 14 May 2021 23:21:52 +0000 Subject: [PATCH 04/18] Add another file to Makefile --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.am b/src/Makefile.am index ddf1e85f24a39..1a8b628e122bc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -102,6 +102,7 @@ nobase_include_HEADERS = \ google/protobuf/generated_message_table_driven.h \ google/protobuf/generated_message_tctable_decl.h \ google/protobuf/generated_message_tctable_impl.h \ + google/protobuf/generated_message_tctable_impl.inc \ google/protobuf/generated_message_util.h \ google/protobuf/has_bits.h \ google/protobuf/implicit_weak_message.h \ From f44755496fd859785db0830b4940666c829c0c62 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Tue, 18 May 2021 20:44:04 +0000 Subject: [PATCH 05/18] Updating makefile to pass the tests --- src/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 1a8b628e122bc..735e3b84149e5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -892,7 +892,9 @@ endif no_warning_test.cc: echo "// Generated from Makefile.am" > no_warning_test.cc for FILE in $(nobase_include_HEADERS); do \ - echo "#include <$${FILE}>" >> no_warning_test.cc; \ + if [[ $$FILE != *.inc ]]; then \ + echo "#include <$${FILE}>" >> no_warning_test.cc; \ + fi \ done echo "int main(int, char**) { return 0; }" >> no_warning_test.cc From 6319a23bff3c38123a637e7e955444cb50f19e67 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Thu, 20 May 2021 18:52:08 +0000 Subject: [PATCH 06/18] Run update_file_lists.sh --- cmake/extract_includes.bat.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/extract_includes.bat.in b/cmake/extract_includes.bat.in index ad630af511855..3e9418cbfc5f1 100644 --- a/cmake/extract_includes.bat.in +++ b/cmake/extract_includes.bat.in @@ -51,6 +51,9 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_reflec copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_util.h" include\google\protobuf\generated_enum_util.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_reflection.h" include\google\protobuf\generated_message_reflection.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_table_driven.h" include\google\protobuf\generated_message_table_driven.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_tctable_decl.h" include\google\protobuf\generated_message_tctable_decl.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_tctable_impl.h" include\google\protobuf\generated_message_tctable_impl.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_tctable_impl.inc" include\google\protobuf\generated_message_tctable_impl.inc copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_util.h" include\google\protobuf\generated_message_util.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\has_bits.h" include\google\protobuf\has_bits.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\implicit_weak_message.h" include\google\protobuf\implicit_weak_message.h From eb57ffe807e0db2c181af620ce919bf2887676a7 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Thu, 20 May 2021 22:23:29 +0000 Subject: [PATCH 07/18] Reverting last change since tests are still failing --- .../generated_message_reflection_unittest.cc | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/google/protobuf/generated_message_reflection_unittest.cc b/src/google/protobuf/generated_message_reflection_unittest.cc index b4c013a54cda0..cd04ce00a969a 100644 --- a/src/google/protobuf/generated_message_reflection_unittest.cc +++ b/src/google/protobuf/generated_message_reflection_unittest.cc @@ -353,6 +353,46 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsOneof) { TestUtil::ExpectOneofSet1(message2); } +TEST(GeneratedMessageReflectionTest, UnsafeShallowSwapFieldsOneof) { + Arena arena; + auto* message1 = Arena::CreateMessage(&arena); + auto* message2 = Arena::CreateMessage(&arena); + TestUtil::SetOneof1(message1); + + std::vector fields; + const Descriptor* descriptor = message1->GetDescriptor(); + for (int i = 0; i < descriptor->field_count(); i++) { + fields.push_back(descriptor->field(i)); + } + GeneratedMessageReflectionTestHelper::UnsafeShallowSwapFields( + message1, message2, fields); + + TestUtil::ExpectOneofClear(*message1); + TestUtil::ExpectOneofSet1(*message2); +} + +TEST(GeneratedMessageReflectionTest, + UnsafeShallowSwapFieldsOneofExpectShallow) { + Arena arena; + auto* message1 = Arena::CreateMessage(&arena); + auto* message2 = Arena::CreateMessage(&arena); + TestUtil::SetOneof1(message1); + message1->mutable_foo_message()->set_qux_int(1000); + auto* kept_foo_ptr = message1->mutable_foo_message(); + + std::vector fields; + const Descriptor* descriptor = message1->GetDescriptor(); + for (int i = 0; i < descriptor->field_count(); i++) { + fields.push_back(descriptor->field(i)); + } + GeneratedMessageReflectionTestHelper::UnsafeShallowSwapFields( + message1, message2, fields); + + EXPECT_TRUE(message2->has_foo_message()); + EXPECT_EQ(message2->foo_message().qux_int(), 1000); + EXPECT_EQ(kept_foo_ptr, message2->mutable_foo_message()); +} + TEST(GeneratedMessageReflectionTest, RemoveLast) { unittest::TestAllTypes message; TestUtil::ReflectionTester reflection_tester( From 2f8d310048f38ea90cad5e78cbd23f27d09f61c9 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Mon, 24 May 2021 19:28:04 +0000 Subject: [PATCH 08/18] Fixing objc tests --- objectivec/Tests/GPBDescriptorTests.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/objectivec/Tests/GPBDescriptorTests.m b/objectivec/Tests/GPBDescriptorTests.m index 6fa7202bc46fc..bdcc2e893c578 100644 --- a/objectivec/Tests/GPBDescriptorTests.m +++ b/objectivec/Tests/GPBDescriptorTests.m @@ -305,7 +305,7 @@ - (void)testOneofDescriptor { GPBDescriptor *descriptor = [TestOneof2 descriptor]; // All fields should be listed. - XCTAssertEqual(descriptor.fields.count, 17U); + XCTAssertEqual(descriptor.fields.count, 21U); // There are two oneofs in there. XCTAssertEqual(descriptor.oneofs.count, 2U); @@ -330,7 +330,7 @@ - (void)testOneofDescriptor { GPBOneofDescriptor *oneofBar = [descriptor oneofWithName:@"bar"]; XCTAssertNotNil(oneofBar); - XCTAssertEqual(oneofBar.fields.count, 6U); + XCTAssertEqual(oneofBar.fields.count, 10U); // Pointer comparisons. XCTAssertEqual([oneofBar fieldWithNumber:TestOneof2_FieldNumber_BarString], From 021329b7e79a387c7b2cc5d483dd36a55c4c5014 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Tue, 25 May 2021 17:27:07 +0000 Subject: [PATCH 09/18] resolving conflicts --- java/kotlin-lite/pom.xml | 17 ----------------- java/kotlin/pom.xml | 16 ---------------- 2 files changed, 33 deletions(-) diff --git a/java/kotlin-lite/pom.xml b/java/kotlin-lite/pom.xml index c7201ae20b54b..4c7361ba6c0ac 100644 --- a/java/kotlin-lite/pom.xml +++ b/java/kotlin-lite/pom.xml @@ -8,7 +8,6 @@ protobuf-kotlin-lite - bundle Protocol Buffers [Lite] @@ -263,22 +262,6 @@ - - - - org.apache.felix - maven-bundle-plugin - true - - - com.google.protobuf - https://developers.google.com/protocol-buffers/ - com.google.protobuf - com.google.protobuf;version=${project.version} - sun.misc;resolution:=optional,* - - - diff --git a/java/kotlin/pom.xml b/java/kotlin/pom.xml index cf48a1c343132..23f515d19c140 100644 --- a/java/kotlin/pom.xml +++ b/java/kotlin/pom.xml @@ -8,7 +8,6 @@ protobuf-kotlin - bundle Protocol Buffers [Core] @@ -219,21 +218,6 @@ - - - org.apache.felix - maven-bundle-plugin - true - - - com.google.protobuf - https://developers.google.com/protocol-buffers/ - com.google.protobuf - com.google.protobuf;version=${project.version} - sun.misc;resolution:=optional,* - - - From 713f2d0008c97b52f69c6164b750ee9b4b85a643 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Tue, 25 May 2021 17:33:14 +0000 Subject: [PATCH 10/18] Removing files that were added during rebasing --- cmake/extract_includes.bat.in | 3 -- src/Makefile.am | 7 +--- .../generated_message_reflection_unittest.cc | 40 ------------------- 3 files changed, 1 insertion(+), 49 deletions(-) diff --git a/cmake/extract_includes.bat.in b/cmake/extract_includes.bat.in index 3e9418cbfc5f1..ad630af511855 100644 --- a/cmake/extract_includes.bat.in +++ b/cmake/extract_includes.bat.in @@ -51,9 +51,6 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_reflec copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_util.h" include\google\protobuf\generated_enum_util.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_reflection.h" include\google\protobuf\generated_message_reflection.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_table_driven.h" include\google\protobuf\generated_message_table_driven.h -copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_tctable_decl.h" include\google\protobuf\generated_message_tctable_decl.h -copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_tctable_impl.h" include\google\protobuf\generated_message_tctable_impl.h -copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_tctable_impl.inc" include\google\protobuf\generated_message_tctable_impl.inc copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_util.h" include\google\protobuf\generated_message_util.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\has_bits.h" include\google\protobuf\has_bits.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\implicit_weak_message.h" include\google\protobuf\implicit_weak_message.h diff --git a/src/Makefile.am b/src/Makefile.am index 735e3b84149e5..66f8665cb1346 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -100,9 +100,6 @@ nobase_include_HEADERS = \ google/protobuf/generated_enum_util.h \ google/protobuf/generated_message_reflection.h \ google/protobuf/generated_message_table_driven.h \ - google/protobuf/generated_message_tctable_decl.h \ - google/protobuf/generated_message_tctable_impl.h \ - google/protobuf/generated_message_tctable_impl.inc \ google/protobuf/generated_message_util.h \ google/protobuf/has_bits.h \ google/protobuf/implicit_weak_message.h \ @@ -892,9 +889,7 @@ endif no_warning_test.cc: echo "// Generated from Makefile.am" > no_warning_test.cc for FILE in $(nobase_include_HEADERS); do \ - if [[ $$FILE != *.inc ]]; then \ - echo "#include <$${FILE}>" >> no_warning_test.cc; \ - fi \ + echo "#include <$${FILE}>" >> no_warning_test.cc; \ done echo "int main(int, char**) { return 0; }" >> no_warning_test.cc diff --git a/src/google/protobuf/generated_message_reflection_unittest.cc b/src/google/protobuf/generated_message_reflection_unittest.cc index cd04ce00a969a..b4c013a54cda0 100644 --- a/src/google/protobuf/generated_message_reflection_unittest.cc +++ b/src/google/protobuf/generated_message_reflection_unittest.cc @@ -353,46 +353,6 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsOneof) { TestUtil::ExpectOneofSet1(message2); } -TEST(GeneratedMessageReflectionTest, UnsafeShallowSwapFieldsOneof) { - Arena arena; - auto* message1 = Arena::CreateMessage(&arena); - auto* message2 = Arena::CreateMessage(&arena); - TestUtil::SetOneof1(message1); - - std::vector fields; - const Descriptor* descriptor = message1->GetDescriptor(); - for (int i = 0; i < descriptor->field_count(); i++) { - fields.push_back(descriptor->field(i)); - } - GeneratedMessageReflectionTestHelper::UnsafeShallowSwapFields( - message1, message2, fields); - - TestUtil::ExpectOneofClear(*message1); - TestUtil::ExpectOneofSet1(*message2); -} - -TEST(GeneratedMessageReflectionTest, - UnsafeShallowSwapFieldsOneofExpectShallow) { - Arena arena; - auto* message1 = Arena::CreateMessage(&arena); - auto* message2 = Arena::CreateMessage(&arena); - TestUtil::SetOneof1(message1); - message1->mutable_foo_message()->set_qux_int(1000); - auto* kept_foo_ptr = message1->mutable_foo_message(); - - std::vector fields; - const Descriptor* descriptor = message1->GetDescriptor(); - for (int i = 0; i < descriptor->field_count(); i++) { - fields.push_back(descriptor->field(i)); - } - GeneratedMessageReflectionTestHelper::UnsafeShallowSwapFields( - message1, message2, fields); - - EXPECT_TRUE(message2->has_foo_message()); - EXPECT_EQ(message2->foo_message().qux_int(), 1000); - EXPECT_EQ(kept_foo_ptr, message2->mutable_foo_message()); -} - TEST(GeneratedMessageReflectionTest, RemoveLast) { unittest::TestAllTypes message; TestUtil::ReflectionTester reflection_tester( From 3f8f6e925d63b1e938987281e3607de136526ee2 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Tue, 25 May 2021 17:35:03 +0000 Subject: [PATCH 11/18] Removing more files that were added during rebasing --- objectivec/Tests/GPBDescriptorTests.m | 4 ++-- src/Makefile.am | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/objectivec/Tests/GPBDescriptorTests.m b/objectivec/Tests/GPBDescriptorTests.m index bdcc2e893c578..6fa7202bc46fc 100644 --- a/objectivec/Tests/GPBDescriptorTests.m +++ b/objectivec/Tests/GPBDescriptorTests.m @@ -305,7 +305,7 @@ - (void)testOneofDescriptor { GPBDescriptor *descriptor = [TestOneof2 descriptor]; // All fields should be listed. - XCTAssertEqual(descriptor.fields.count, 21U); + XCTAssertEqual(descriptor.fields.count, 17U); // There are two oneofs in there. XCTAssertEqual(descriptor.oneofs.count, 2U); @@ -330,7 +330,7 @@ - (void)testOneofDescriptor { GPBOneofDescriptor *oneofBar = [descriptor oneofWithName:@"bar"]; XCTAssertNotNil(oneofBar); - XCTAssertEqual(oneofBar.fields.count, 10U); + XCTAssertEqual(oneofBar.fields.count, 6U); // Pointer comparisons. XCTAssertEqual([oneofBar fieldWithNumber:TestOneof2_FieldNumber_BarString], diff --git a/src/Makefile.am b/src/Makefile.am index 66f8665cb1346..c584d20ccca60 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -889,7 +889,7 @@ endif no_warning_test.cc: echo "// Generated from Makefile.am" > no_warning_test.cc for FILE in $(nobase_include_HEADERS); do \ - echo "#include <$${FILE}>" >> no_warning_test.cc; \ + echo "#include <$${FILE}>" >> no_warning_test.cc; \ done echo "int main(int, char**) { return 0; }" >> no_warning_test.cc From 5fac12fff0358dd944c855d67250bacdb6c92e57 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Tue, 25 May 2021 17:38:17 +0000 Subject: [PATCH 12/18] Reverting the Makefile spacing changes --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index c584d20ccca60..12eb70743bbbd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -889,7 +889,7 @@ endif no_warning_test.cc: echo "// Generated from Makefile.am" > no_warning_test.cc for FILE in $(nobase_include_HEADERS); do \ - echo "#include <$${FILE}>" >> no_warning_test.cc; \ + echo "#include <$${FILE}>" >> no_warning_test.cc; \ done echo "int main(int, char**) { return 0; }" >> no_warning_test.cc From 5b8208eceadb53ab53bdf7f4ee1ce7591501d0c2 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Tue, 25 May 2021 19:36:05 +0000 Subject: [PATCH 13/18] Update protobuf version --- Protobuf-C++.podspec | 2 +- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/kotlin-lite/pom.xml | 2 +- java/kotlin/pom.xml | 2 +- java/lite/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 23 +++++++++++++++---- php/ext/google/protobuf/protobuf.h | 2 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- src/Makefile.am | 2 +- src/google/protobuf/any.pb.h | 2 +- src/google/protobuf/api.pb.h | 2 +- src/google/protobuf/compiler/plugin.pb.h | 2 +- src/google/protobuf/descriptor.pb.h | 2 +- src/google/protobuf/duration.pb.h | 2 +- src/google/protobuf/empty.pb.h | 2 +- src/google/protobuf/field_mask.pb.h | 2 +- src/google/protobuf/port_def.inc | 2 +- src/google/protobuf/source_context.pb.h | 2 +- src/google/protobuf/struct.pb.h | 2 +- src/google/protobuf/stubs/common.h | 2 +- src/google/protobuf/timestamp.pb.h | 2 +- src/google/protobuf/type.pb.h | 2 +- src/google/protobuf/wrappers.pb.h | 2 +- 33 files changed, 51 insertions(+), 36 deletions(-) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index fbb1ef9265bc4..18d262dcc77bc 100644 --- a/Protobuf-C++.podspec +++ b/Protobuf-C++.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Protobuf-C++' - s.version = '3.17.1' + s.version = '3.17.2' s.summary = 'Protocol Buffers v3 runtime library for C++.' s.homepage = 'https://github.com/google/protobuf' s.license = '3-Clause BSD License' diff --git a/Protobuf.podspec b/Protobuf.podspec index 0f98517bcd0df..30d8e64d4eca5 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -5,7 +5,7 @@ # dependent projects use the :git notation to refer to the library. Pod::Spec.new do |s| s.name = 'Protobuf' - s.version = '3.17.1' + s.version = '3.17.2' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = '3-Clause BSD License' diff --git a/configure.ac b/configure.ac index 0c1276b734092..bf6251644363a 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ AC_PREREQ(2.59) # In the SVN trunk, the version should always be the next anticipated release # version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[3.17.1],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.17.2],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 3cec102d3fb0a..3e2bc21ffd98b 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.17.1 + 3.17.2 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 5348df09e2e36..01f0a53ed0563 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.17.1 + 3.17.2 7.2 Google Inc. diff --git a/java/bom/pom.xml b/java/bom/pom.xml index b4a757f49f2cb..b78963ee8d7a1 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.17.1 + 3.17.2 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index 97b0c3beba34b..1855ba7629adf 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.17.1 + 3.17.2 protobuf-java diff --git a/java/kotlin-lite/pom.xml b/java/kotlin-lite/pom.xml index 4c7361ba6c0ac..409ba220bedcc 100644 --- a/java/kotlin-lite/pom.xml +++ b/java/kotlin-lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.17.1 + 3.17.2 protobuf-kotlin-lite diff --git a/java/kotlin/pom.xml b/java/kotlin/pom.xml index 23f515d19c140..6e8c93dcac595 100644 --- a/java/kotlin/pom.xml +++ b/java/kotlin/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.17.1 + 3.17.2 protobuf-kotlin diff --git a/java/lite/pom.xml b/java/lite/pom.xml index ef7c1d58b9fe0..8887c8a72f187 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.17.1 + 3.17.2 protobuf-javalite diff --git a/java/pom.xml b/java/pom.xml index d6d8001ee6c7e..5cfb67f6b779e 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.17.1 + 3.17.2 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index 34b5d3d2b1869..e4d3df2c24d60 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.17.1 + 3.17.2 protobuf-java-util diff --git a/js/package.json b/js/package.json index 3886918e6a92e..f126067ab4d0f 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.17.1", + "version": "3.17.2", "description": "Protocol Buffers for JavaScript", "main": "google-protobuf.js", "files": [ diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index 829d7c9a6e8b8..3f86baf953efc 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,11 +10,11 @@ protobuf-opensource@google.com yes - 2021-05-19 - + 2021-05-25 + - 3.17.1 - 3.17.1 + 3.17.2 + 3.17.2 stable @@ -982,5 +982,20 @@ G A release. all but one are null. + + + 3.17.2 + 3.17.2 + + + stable + stable + + 2021-05-25 + + 3-Clause BSD License + + + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 530efbd8e4a1a..7d30d26e0cfbc 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -81,7 +81,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_setter, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -#define PHP_PROTOBUF_VERSION "3.17.1" +#define PHP_PROTOBUF_VERSION "3.17.2" // ptr -> PHP object cache. This is a weak map that caches lazily-created // wrapper objects around upb types: diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index c1ff3a6f90841..54e1e269bfd93 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.17.1 + 3.17.2 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 9f66585651540..67502f0fc80be 100644 --- a/python/google/protobuf/__init__.py +++ b/python/google/protobuf/__init__.py @@ -30,4 +30,4 @@ # Copyright 2007 Google Inc. All Rights Reserved. -__version__ = '3.17.1' +__version__ = '3.17.2' diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index bfc053f49c87c..322939b8db161 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.17.1" + s.version = "3.17.2" git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers" diff --git a/src/Makefile.am b/src/Makefile.am index 12eb70743bbbd..d62aef28f32c0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ else PTHREAD_DEF = endif -PROTOBUF_VERSION = 28:1:0 +PROTOBUF_VERSION = 28:2:0 if GCC # Turn on all warnings except for sign comparison (we ignore sign comparison diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 8dc01caeed5c6..e7836ba5a739d 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3017001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3017002 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 1f92d4337f53a..7fb45f00aa8a2 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3017001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3017002 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 0cb7941eaa0cd..3a2dd0608bfec 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3017001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3017002 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index ad1ce4c057b9c..5ec12dcf11290 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3017001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3017002 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index ef343d99011df..05a65ab594a0e 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3017001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3017002 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 40a77fed6c6ae..57f4f04be07bb 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3017001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3017002 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index e71551e822132..dab327f8acc52 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3017001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3017002 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 61f085970d9cb..e0406be150235 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -107,7 +107,7 @@ #ifdef PROTOBUF_VERSION #error PROTOBUF_VERSION was previously defined #endif -#define PROTOBUF_VERSION 3017001 +#define PROTOBUF_VERSION 3017002 #ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC #error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index cf2999e630554..9867f0b4aaa11 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3017001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3017002 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index 0fec29c0f0e76..d47ae123b1923 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3017001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3017002 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 497a91e266a3a..06ace3d67e9ce 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -82,7 +82,7 @@ namespace internal { // The current version, represented as a single integer to make comparison // easier: major * 10^6 + minor * 10^3 + micro -#define GOOGLE_PROTOBUF_VERSION 3017001 +#define GOOGLE_PROTOBUF_VERSION 3017002 // A suffix string for alpha, beta or rc releases. Empty for stable releases. #define GOOGLE_PROTOBUF_VERSION_SUFFIX "" diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 3acaca9c482f8..2970c1a34703f 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3017001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3017002 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 3242d4b8908f5..1ea54e3f93d5d 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3017001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3017002 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index e890dffba90f3..9f94177ffa6be 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3017001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3017002 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. From d303bba1bb542e499bf39c7bec86a6c0c8e7da90 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Tue, 25 May 2021 21:02:52 +0000 Subject: [PATCH 14/18] Updating change logs --- CHANGES.txt | 4 ++++ php/ext/google/protobuf/package.xml | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 395f2088b6887..55e45f5cd6a74 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +2021-05-25 version 3.17.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + Kotlin + * Fix duplicate class error + 2021-05-07 version 3.17.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) PHP * Fixed PHP memory leaks and arginfo errors. (#8614) diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index 3f86baf953efc..b27ac4bbee61b 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -22,9 +22,7 @@ 3-Clause BSD License - * Fixed PHP memory leaks and arginfo errors. (#8614) - * Fixed JSON parser to allow multiple values from the same oneof as long as - all but one are null. + * No new changes in 3.17.2 From a693d723d4552a49bb2d180996a26e40c750334e Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Tue, 25 May 2021 21:07:28 +0000 Subject: [PATCH 15/18] Add PR number for kotlin fix --- CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 55e45f5cd6a74..4fa0ac73661de 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,6 @@ 2021-05-25 version 3.17.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) Kotlin - * Fix duplicate class error + * Fix duplicate class error (#8653) 2021-05-07 version 3.17.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) PHP From 75de6aa21a1039251eb7f747f5b84164a90a8e5f Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Thu, 27 May 2021 09:55:45 -0700 Subject: [PATCH 16/18] Fixed sub-message getters for well-known types when message is unset. The well-known types generate C code into wkt.inc, and this C code was not testing isset($msg->submsg_field) like the generated code does: ```php // PHP generated getter: checks isset(). public function getOptions() { return isset($this->options) ? $this->options : null; } ``` ```c // C generated getter, does not check upb_msg_has() static PHP_METHOD(google_protobuf_Value, getListValue) { Message* intern = (Message*)Z_OBJ_P(getThis()); const upb_fielddef *f = upb_msgdef_ntofz(intern->desc->msgdef, "list_value"); zval ret; Message_get(intern, f, &ret); RETURN_COPY_VALUE(&ret); } ``` This led to an error where we wnuld try to get a sub-message field from upb when it `upb_msg_has(msg, field) == false`, which is an error according to upb. There are two possible fixes for this bug. A guiding principle is that we want the generated C code in wkt.inc to have the same behavior as PHP generated code. Following this principle, the two possible fixes are: 1. Change the code generator for wkt.inc to check upb_msg_has(f) before calling Message_get(). This would match the isset() check that the The PHP generated code does, and we would leave the PHP code unchanged. 2. Change Message_get() to itself perform the upb_msg_has(f) check for sub-message fields. This means that generated code would no longer need to perform an isset() check, so we would want to remove this check from the PHP generated code also to avoid a redundant check. Both of these are reasonable fixes, and it is not immediately obvious which is better. (1) has the benefit of resolving this case when we are in more specialized code (a getter function that already knows this is a sub-message field), and therefore avoids performing the check later in more generic code that would have to test the type again. On the other hand, the isset() check is not needed for the pure PHP implementation, as an unset PHP variable will return `null` anyway. And for the C extension, we'd rather check upb_msg_has() at the C level instead of PHP. So this change implements (2). The generated code in wkt.inc remains unchanged, and the PHP generated code for sub-message fields is changed to remove the isset() check. --- php/ext/google/protobuf/message.c | 5 ++- php/src/Google/Protobuf/Api.php | 2 +- php/src/Google/Protobuf/Enum.php | 2 +- .../Protobuf/Internal/DescriptorProto.php | 2 +- .../DescriptorProto/ExtensionRange.php | 2 +- .../Protobuf/Internal/EnumDescriptorProto.php | 2 +- .../Internal/EnumValueDescriptorProto.php | 2 +- .../Internal/FieldDescriptorProto.php | 2 +- .../Protobuf/Internal/FileDescriptorProto.php | 4 +- .../Internal/MethodDescriptorProto.php | 2 +- .../Internal/OneofDescriptorProto.php | 2 +- .../Internal/ServiceDescriptorProto.php | 2 +- php/src/Google/Protobuf/Option.php | 2 +- php/src/Google/Protobuf/Type.php | 2 +- php/tests/GeneratedClassTest.php | 2 + php/tests/WellKnownTest.php | 2 + .../protobuf/compiler/php/php_generator.cc | 41 +++++++++++++------ 17 files changed, 50 insertions(+), 28 deletions(-) diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index b32b325555dc1..7a1aefa6f7299 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -134,6 +134,10 @@ static void Message_get(Message *intern, const upb_fielddef *f, zval *rv) { RepeatedField_GetPhpWrapper(rv, msgval.array, TypeInfo_Get(f), &intern->arena); } else { + if (upb_fielddef_issubmsg(f) && !upb_msg_has(intern->msg, f)) { + ZVAL_NULL(rv); + return; + } upb_msgval msgval = upb_msg_get(intern->msg, f); Convert_UpbToPhp(msgval, rv, TypeInfo_Get(f), &intern->arena); } @@ -280,7 +284,6 @@ static int Message_has_property(PROTO_VAL *obj, PROTO_STR *member, * Message_unset_property() * * Object handler for unsetting a property. Called when PHP code calls: - * does any of: * * unset($message->foobar); * diff --git a/php/src/Google/Protobuf/Api.php b/php/src/Google/Protobuf/Api.php index 7cbb30eb42846..e7d76c01d6cfe 100644 --- a/php/src/Google/Protobuf/Api.php +++ b/php/src/Google/Protobuf/Api.php @@ -275,7 +275,7 @@ public function setVersion($var) */ public function getSourceContext() { - return isset($this->source_context) ? $this->source_context : null; + return $this->source_context; } public function hasSourceContext() diff --git a/php/src/Google/Protobuf/Enum.php b/php/src/Google/Protobuf/Enum.php index 2e0ac9987b6b8..e803e930d8f21 100644 --- a/php/src/Google/Protobuf/Enum.php +++ b/php/src/Google/Protobuf/Enum.php @@ -155,7 +155,7 @@ public function setOptions($var) */ public function getSourceContext() { - return isset($this->source_context) ? $this->source_context : null; + return $this->source_context; } public function hasSourceContext() diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php index ff308e7eeb146..c58c5739e57ff 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php @@ -256,7 +256,7 @@ public function setOneofDecl($var) */ public function getOptions() { - return isset($this->options) ? $this->options : null; + return $this->options; } public function hasOptions() diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php index bbe4a6a84f9f8..43c33c4a91034 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php @@ -128,7 +128,7 @@ public function setEnd($var) */ public function getOptions() { - return isset($this->options) ? $this->options : null; + return $this->options; } public function hasOptions() diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php index b9b634282906e..bd50834f81834 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php @@ -128,7 +128,7 @@ public function setValue($var) */ public function getOptions() { - return isset($this->options) ? $this->options : null; + return $this->options; } public function hasOptions() diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php index eff1452eed4eb..0feaea6f182f4 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php @@ -116,7 +116,7 @@ public function setNumber($var) */ public function getOptions() { - return isset($this->options) ? $this->options : null; + return $this->options; } public function hasOptions() diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php index 94e5fe12ecc9e..9cf6f10cfd2a7 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php @@ -515,7 +515,7 @@ public function setJsonName($var) */ public function getOptions() { - return isset($this->options) ? $this->options : null; + return $this->options; } public function hasOptions() diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php index d96c7a78ecc51..435bd5fb6f061 100644 --- a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php @@ -375,7 +375,7 @@ public function setExtension($var) */ public function getOptions() { - return isset($this->options) ? $this->options : null; + return $this->options; } public function hasOptions() @@ -412,7 +412,7 @@ public function setOptions($var) */ public function getSourceCodeInfo() { - return isset($this->source_code_info) ? $this->source_code_info : null; + return $this->source_code_info; } public function hasSourceCodeInfo() diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php index 5814f08852961..96efb02d24a10 100644 --- a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php @@ -180,7 +180,7 @@ public function setOutputType($var) */ public function getOptions() { - return isset($this->options) ? $this->options : null; + return $this->options; } public function hasOptions() diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php index 33cf487a8a2ba..3cb9f25c212d2 100644 --- a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php @@ -79,7 +79,7 @@ public function setName($var) */ public function getOptions() { - return isset($this->options) ? $this->options : null; + return $this->options; } public function hasOptions() diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php index f60561c1822cb..c511247692cb7 100644 --- a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php @@ -106,7 +106,7 @@ public function setMethod($var) */ public function getOptions() { - return isset($this->options) ? $this->options : null; + return $this->options; } public function hasOptions() diff --git a/php/src/Google/Protobuf/Option.php b/php/src/Google/Protobuf/Option.php index 5166a08db6157..31249e5131145 100644 --- a/php/src/Google/Protobuf/Option.php +++ b/php/src/Google/Protobuf/Option.php @@ -101,7 +101,7 @@ public function setName($var) */ public function getValue() { - return isset($this->value) ? $this->value : null; + return $this->value; } public function hasValue() diff --git a/php/src/Google/Protobuf/Type.php b/php/src/Google/Protobuf/Type.php index 3f2835927396c..41b9e3602f84f 100644 --- a/php/src/Google/Protobuf/Type.php +++ b/php/src/Google/Protobuf/Type.php @@ -189,7 +189,7 @@ public function setOptions($var) */ public function getSourceContext() { - return isset($this->source_context) ? $this->source_context : null; + return $this->source_context; } public function hasSourceContext() diff --git a/php/tests/GeneratedClassTest.php b/php/tests/GeneratedClassTest.php index 5c0f0c70d0ee7..540105c376b72 100644 --- a/php/tests/GeneratedClassTest.php +++ b/php/tests/GeneratedClassTest.php @@ -472,6 +472,8 @@ public function testMessageField() { $m = new TestMessage(); + $this->assertNull($m->getOptionalMessage()); + $sub_m = new Sub(); $sub_m->setA(1); $m->setOptionalMessage($sub_m); diff --git a/php/tests/WellKnownTest.php b/php/tests/WellKnownTest.php index 27b7e1463cec8..486c65ffca8e1 100644 --- a/php/tests/WellKnownTest.php +++ b/php/tests/WellKnownTest.php @@ -270,6 +270,8 @@ public function testStruct() $m = new Value(); + $this->assertNull($m->getStructValue()); + $m->setNullValue(NullValue::NULL_VALUE); $this->assertSame(NullValue::NULL_VALUE, $m->getNullValue()); $this->assertSame("null_value", $m->getKind()); diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 45eb4c619637a..f351ccd2a48e0 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -648,32 +648,21 @@ void GenerateFieldAccessor(const FieldDescriptor* field, const Options& options, std::string deprecation_trigger = (field->options().deprecated()) ? "@trigger_error('" + field->name() + " is deprecated.', E_USER_DEPRECATED);\n " : ""; + // Emit getter. if (oneof != NULL) { printer->Print( "public function get^camel_name^()\n" "{\n" " ^deprecation_trigger^return $this->readOneof(^number^);\n" - "}\n\n" - "public function has^camel_name^()\n" - "{\n" - " ^deprecation_trigger^return $this->hasOneof(^number^);\n" "}\n\n", "camel_name", UnderscoresToCamelCase(field->name(), true), "number", IntToString(field->number()), "deprecation_trigger", deprecation_trigger); - } else if (field->has_presence()) { + } else if (field->has_presence() && !field->message_type()) { printer->Print( "public function get^camel_name^()\n" "{\n" " ^deprecation_trigger^return isset($this->^name^) ? $this->^name^ : ^default_value^;\n" - "}\n\n" - "public function has^camel_name^()\n" - "{\n" - " ^deprecation_trigger^return isset($this->^name^);\n" - "}\n\n" - "public function clear^camel_name^()\n" - "{\n" - " ^deprecation_trigger^unset($this->^name^);\n" "}\n\n", "camel_name", UnderscoresToCamelCase(field->name(), true), "name", field->name(), @@ -690,6 +679,32 @@ void GenerateFieldAccessor(const FieldDescriptor* field, const Options& options, "deprecation_trigger", deprecation_trigger); } + // Emit hazzers/clear. + if (oneof) { + printer->Print( + "public function has^camel_name^()\n" + "{\n" + " ^deprecation_trigger^return $this->hasOneof(^number^);\n" + "}\n\n", + "camel_name", UnderscoresToCamelCase(field->name(), true), + "number", IntToString(field->number()), + "deprecation_trigger", deprecation_trigger); + } else if (field->has_presence()) { + printer->Print( + "public function has^camel_name^()\n" + "{\n" + " ^deprecation_trigger^return isset($this->^name^);\n" + "}\n\n" + "public function clear^camel_name^()\n" + "{\n" + " ^deprecation_trigger^unset($this->^name^);\n" + "}\n\n", + "camel_name", UnderscoresToCamelCase(field->name(), true), + "name", field->name(), + "default_value", DefaultForField(field), + "deprecation_trigger", deprecation_trigger); + } + // For wrapper types, generate an additional getXXXUnwrapped getter if (!field->is_map() && !field->is_repeated() && From 7090f7ab55f34abea66d6ba090c28c52e6eb73dc Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Tue, 1 Jun 2021 23:04:16 +0000 Subject: [PATCH 17/18] Adding dokka to main pom --- java/pom.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/java/pom.xml b/java/pom.xml index 5cfb67f6b779e..3a774ec2b00b8 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -228,6 +228,19 @@ false + + org.jetbrains.dokka + dokka-maven-plugin + 1.4.32 + + + prepare-package + + javadocJar + + + + From c26e452e9e008bc18094cca9ecff1efd37f963be Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Wed, 2 Jun 2021 16:22:31 +0000 Subject: [PATCH 18/18] Adding PHP fix to changes for 3.17.2 --- CHANGES.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 4fa0ac73661de..f9d694a7c4914 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,10 @@ Kotlin * Fix duplicate class error (#8653) + PHP + * Fixed SEGV in sub-message getters for well-known types when message is unset + (#8670) + 2021-05-07 version 3.17.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) PHP * Fixed PHP memory leaks and arginfo errors. (#8614)