From 53944b59834d8783792904f006445f90b835e9e6 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 25 May 2022 10:46:25 -0700 Subject: [PATCH 01/31] Add back "fix: reserve "ReadOnly" keyword for PHP 8.1 and add compatibility (#9633)" --- php/ext/google/protobuf/names.c | 12 +-- php/src/Google/Protobuf/Internal/GPBUtil.php | 11 +- php/tests/GeneratedClassTest.php | 18 ++++ .../proto/test_reserved_enum_lower.proto | 1 + .../proto/test_reserved_enum_upper.proto | 1 + .../test_reserved_enum_value_lower.proto | 1 + .../test_reserved_enum_value_upper.proto | 1 + .../proto/test_reserved_message_lower.proto | 1 + .../proto/test_reserved_message_upper.proto | 1 + .../protobuf/compiler/php/php_generator.cc | 100 ++++++++++++++---- 10 files changed, 117 insertions(+), 30 deletions(-) diff --git a/php/ext/google/protobuf/names.c b/php/ext/google/protobuf/names.c index 5d7b68aaf5dd4..a2988816ed0dc 100644 --- a/php/ext/google/protobuf/names.c +++ b/php/ext/google/protobuf/names.c @@ -82,12 +82,12 @@ const char *const kReservedNames[] = { "global", "goto", "insteadof", "interface", "isset", "list", "match", "namespace", "new", "object", "or", "parent", "print", "private", "protected", - "public", "require", "require_once", "return", "self", - "static", "switch", "throw", "trait", "try", - "unset", "use", "var", "while", "xor", - "yield", "int", "float", "bool", "string", - "true", "false", "null", "void", "iterable", - NULL}; + "public", "readonly", "require", "require_once", "return", + "self", "static", "switch", "throw", "trait", + "try", "unset", "use", "var", "while", + "xor", "yield", "int", "float", "bool", + "string", "true", "false", "null", "void", + "iterable", NULL}; bool is_reserved_name(const char* name) { int i; diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php index 4b152839ec5e5..d7f2faaf6c580 100644 --- a/php/src/Google/Protobuf/Internal/GPBUtil.php +++ b/php/src/Google/Protobuf/Internal/GPBUtil.php @@ -285,11 +285,12 @@ public static function getClassNamePrefix( "include"=>0, "include_once"=>0, "instanceof"=>0, "insteadof"=>0, "interface"=>0, "isset"=>0, "list"=>0, "match"=>0, "namespace"=>0, "new"=>0, "or"=>0, "parent"=>0, "print"=>0, "private"=>0, - "protected"=>0,"public"=>0, "require"=>0, "require_once"=>0, - "return"=>0, "self"=>0, "static"=>0, "switch"=>0, "throw"=>0, - "trait"=>0, "try"=>0,"unset"=>0, "use"=>0, "var"=>0, "while"=>0, - "xor"=>0, "yield"=>0, "int"=>0, "float"=>0, "bool"=>0, "string"=>0, - "true"=>0, "false"=>0, "null"=>0, "void"=>0, "iterable"=>0 + "protected"=>0,"public"=>0, "readonly" => 0,"require"=>0, + "require_once"=>0,"return"=>0, "self"=>0, "static"=>0, "switch"=>0, + "throw"=>0,"trait"=>0, "try"=>0,"unset"=>0, "use"=>0, "var"=>0, + "while"=>0,"xor"=>0, "yield"=>0, "int"=>0, "float"=>0, "bool"=>0, + "string"=>0,"true"=>0, "false"=>0, "null"=>0, "void"=>0, + "iterable"=>0 ); if (array_key_exists(strtolower($classname), $reserved_words)) { diff --git a/php/tests/GeneratedClassTest.php b/php/tests/GeneratedClassTest.php index 8a89973ce8041..37c33dfabec1b 100644 --- a/php/tests/GeneratedClassTest.php +++ b/php/tests/GeneratedClassTest.php @@ -334,6 +334,18 @@ public function testLegacyTypehintWithNestedEnums() $this->legacyEnum(new TestLegacyMessage\NestedEnum); } + public function testLegacyReadOnlyMessage() + { + $this->assertTrue(class_exists('\Upper\READONLY')); + $this->assertTrue(class_exists('\Lower\readonly')); + } + + public function testLegacyReadOnlyEnum() + { + $this->assertTrue(class_exists('\Upper_enum\READONLY')); + $this->assertTrue(class_exists('\Lower_enum\readonly')); + } + private function legacyEnum(TestLegacyMessage_NestedEnum $enum) { // If we made it here without a PHP Fatal error, the typehint worked @@ -943,6 +955,7 @@ public function testPrefixForReservedWords() $m = new \Lower\PBprivate(); $m = new \Lower\PBprotected(); $m = new \Lower\PBpublic(); + $m = new \Lower\PBreadonly(); $m = new \Lower\PBrequire(); $m = new \Lower\PBrequire_once(); $m = new \Lower\PBreturn(); @@ -1023,6 +1036,7 @@ public function testPrefixForReservedWords() $m = new \Upper\PBPRIVATE(); $m = new \Upper\PBPROTECTED(); $m = new \Upper\PBPUBLIC(); + $m = new \Upper\PBREADONLY(); $m = new \Upper\PBREQUIRE(); $m = new \Upper\PBREQUIRE_ONCE(); $m = new \Upper\PBRETURN(); @@ -1104,6 +1118,7 @@ public function testPrefixForReservedWords() $m = new \Lower_enum\PBprotected(); $m = new \Lower_enum\PBpublic(); $m = new \Lower_enum\PBrequire(); + $m = new \Lower_enum\PBreadonly(); $m = new \Lower_enum\PBrequire_once(); $m = new \Lower_enum\PBreturn(); $m = new \Lower_enum\PBself(); @@ -1183,6 +1198,7 @@ public function testPrefixForReservedWords() $m = new \Upper_enum\PBPRIVATE(); $m = new \Upper_enum\PBPROTECTED(); $m = new \Upper_enum\PBPUBLIC(); + $m = new \Upper_enum\PBREADONLY(); $m = new \Upper_enum\PBREQUIRE(); $m = new \Upper_enum\PBREQUIRE_ONCE(); $m = new \Upper_enum\PBRETURN(); @@ -1287,6 +1303,7 @@ public function testPrefixForReservedWords() $m = \Lower_enum_value\NotAllowed::iterable; $m = \Lower_enum_value\NotAllowed::parent; $m = \Lower_enum_value\NotAllowed::self; + $m = \Lower_enum_value\NotAllowed::readonly; $m = \Upper_enum_value\NotAllowed::PBABSTRACT; $m = \Upper_enum_value\NotAllowed::PBAND; @@ -1367,6 +1384,7 @@ public function testPrefixForReservedWords() $m = \Upper_enum_value\NotAllowed::ITERABLE; $m = \Upper_enum_value\NotAllowed::PARENT; $m = \Upper_enum_value\NotAllowed::SELF; + $m = \Upper_enum_value\NotAllowed::READONLY; $this->assertTrue(true); } diff --git a/php/tests/proto/test_reserved_enum_lower.proto b/php/tests/proto/test_reserved_enum_lower.proto index f8557d250fea9..1f96ac6fe0206 100644 --- a/php/tests/proto/test_reserved_enum_lower.proto +++ b/php/tests/proto/test_reserved_enum_lower.proto @@ -57,6 +57,7 @@ enum print { ZERO51 = 0; } enum private { ZERO52 = 0; } enum protected { ZERO53 = 0; } enum public { ZERO54 = 0; } +enum readonly { ZERO80 = 0; } enum require { ZERO55 = 0; } enum require_once { ZERO56 = 0; } enum return { ZERO57 = 0; } diff --git a/php/tests/proto/test_reserved_enum_upper.proto b/php/tests/proto/test_reserved_enum_upper.proto index 8d382ab31e5d3..c5e7e99fd5ddf 100644 --- a/php/tests/proto/test_reserved_enum_upper.proto +++ b/php/tests/proto/test_reserved_enum_upper.proto @@ -57,6 +57,7 @@ enum PRINT { ZERO51 = 0; } enum PRIVATE { ZERO52 = 0; } enum PROTECTED { ZERO53 = 0; } enum PUBLIC { ZERO54 = 0; } +enum READONLY { ZERO80 = 0; } enum REQUIRE { ZERO55 = 0; } enum REQUIRE_ONCE { ZERO56 = 0; } enum RETURN { ZERO57 = 0; } diff --git a/php/tests/proto/test_reserved_enum_value_lower.proto b/php/tests/proto/test_reserved_enum_value_lower.proto index ca5a7c7352a09..86c6877f7d889 100644 --- a/php/tests/proto/test_reserved_enum_value_lower.proto +++ b/php/tests/proto/test_reserved_enum_value_lower.proto @@ -58,6 +58,7 @@ enum NotAllowed { private = 51; protected = 52; public = 53; + readonly = 79; require = 54; require_once = 55; return = 56; diff --git a/php/tests/proto/test_reserved_enum_value_upper.proto b/php/tests/proto/test_reserved_enum_value_upper.proto index 6b4040d5e4ab6..ac0beda7d9036 100644 --- a/php/tests/proto/test_reserved_enum_value_upper.proto +++ b/php/tests/proto/test_reserved_enum_value_upper.proto @@ -58,6 +58,7 @@ enum NotAllowed { PRIVATE = 51; PROTECTED = 52; PUBLIC = 53; + READONLY = 79; REQUIRE = 54; REQUIRE_ONCE = 55; RETURN = 56; diff --git a/php/tests/proto/test_reserved_message_lower.proto b/php/tests/proto/test_reserved_message_lower.proto index 2390a87dd696e..551ed7a408d4b 100644 --- a/php/tests/proto/test_reserved_message_lower.proto +++ b/php/tests/proto/test_reserved_message_lower.proto @@ -57,6 +57,7 @@ message print {} message private {} message protected {} message public {} +message readonly {} message require {} message require_once {} message return {} diff --git a/php/tests/proto/test_reserved_message_upper.proto b/php/tests/proto/test_reserved_message_upper.proto index 9f55330223472..96995c99178af 100644 --- a/php/tests/proto/test_reserved_message_upper.proto +++ b/php/tests/proto/test_reserved_message_upper.proto @@ -57,6 +57,7 @@ message PRINT {} message PRIVATE {} message PROTECTED {} message PUBLIC {} +message READONLY {} message REQUIRE {} message REQUIRE_ONCE {} message RETURN {} diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 85671f7c9cbaf..135a92f6545ab 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -48,29 +48,29 @@ const std::string kDescriptorMetadataFile = const std::string kDescriptorDirName = "Google/Protobuf/Internal"; const std::string kDescriptorPackageName = "Google\\Protobuf\\Internal"; const char* const kReservedNames[] = { - "abstract", "and", "array", "as", "break", - "callable", "case", "catch", "class", "clone", - "const", "continue", "declare", "default", "die", - "do", "echo", "else", "elseif", "empty", - "enddeclare", "endfor", "endforeach", "endif", "endswitch", - "endwhile", "eval", "exit", "extends", "final", - "finally", "fn", "for", "foreach", "function", - "global", "goto", "if", "implements", "include", - "include_once", "instanceof", "insteadof", "interface", "isset", - "list", "match", "namespace", "new", "or", - "parent", "print", "private", "protected", "public", - "require", "require_once", "return", "self", "static", - "switch", "throw", "trait", "try", "unset", - "use", "var", "while", "xor", "yield", - "int", "float", "bool", "string", "true", - "false", "null", "void", "iterable"}; + "abstract", "and", "array", "as", "break", + "callable", "case", "catch", "class", "clone", + "const", "continue", "declare", "default", "die", + "do", "echo", "else", "elseif", "empty", + "enddeclare", "endfor", "endforeach", "endif", "endswitch", + "endwhile", "eval", "exit", "extends", "final", + "finally", "fn", "for", "foreach", "function", + "global", "goto", "if", "implements", "include", + "include_once", "instanceof", "insteadof", "interface", "isset", + "list", "match", "namespace", "new", "or", + "parent", "print", "private", "protected", "public", + "readonly", "require", "require_once", "return", "self", + "static", "switch", "throw", "trait", "try", + "unset", "use", "var", "while", "xor", + "yield", "int", "float", "bool", "string", + "true", "false", "null", "void", "iterable"}; const char* const kValidConstantNames[] = { "int", "float", "bool", "string", "true", "false", "null", "void", "iterable", "parent", - "self" + "self", "readonly" }; -const int kReservedNamesSize = 79; -const int kValidConstantNamesSize = 11; +const int kReservedNamesSize = 80; +const int kValidConstantNamesSize = 12; const int kFieldSetter = 1; const int kFieldGetter = 2; const int kFieldProperty = 3; @@ -420,6 +420,16 @@ std::string LegacyGeneratedClassFileName(const DescriptorType* desc, return result + ".php"; } +template +std::string LegacyReadOnlyGeneratedClassFileName(const DescriptorType* desc, + const Options& options) { + std::string php_namespace = RootPhpNamespace(desc, options); + if (!php_namespace.empty()) { + return php_namespace + "/" + desc->name() + ".php"; + } + return desc->name() + ".php"; +} + std::string GeneratedServiceFileName(const ServiceDescriptor* service, const Options& options) { std::string result = FullClassName(service, options) + "Interface"; @@ -1302,6 +1312,32 @@ void LegacyGenerateClassFile(const FileDescriptor* file, "fullname", newname); } +template +void LegacyReadOnlyGenerateClassFile(const FileDescriptor* file, + const DescriptorType* desc, const Options& options, + GeneratorContext* generator_context) { + std::string filename = LegacyReadOnlyGeneratedClassFileName(desc, options); + std::unique_ptr output( + generator_context->Open(filename)); + io::Printer printer(output.get(), '^'); + + GenerateHead(file, &printer); + + std::string php_namespace = RootPhpNamespace(desc, options); + if (!php_namespace.empty()) { + printer.Print( + "namespace ^name^;\n\n", + "name", php_namespace); + } + std::string newname = FullClassName(desc, options); + printer.Print("class_exists(^new^::class);\n", + "new", GeneratedClassNameImpl(desc)); + printer.Print("@trigger_error(__NAMESPACE__ . '\\^old^ is deprecated and will be removed in " + "the next major release. Use ^fullname^ instead', E_USER_DEPRECATED);\n\n", + "old", desc->name(), + "fullname", newname); +} + void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, const Options& options, GeneratorContext* generator_context) { @@ -1423,6 +1459,19 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, "old", LegacyFullClassName(en, options)); LegacyGenerateClassFile(file, en, options, generator_context); } + + // Write legacy file for backwards compatibility with "readonly" keywword + std::string lower = en->name(); + std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower); + if (lower == "readonly") { + printer.Print( + "// Adding a class alias for backwards compatibility with the \"readonly\" keyword.\n"); + printer.Print( + "class_alias(^new^::class, __NAMESPACE__ . '\\^old^');\n\n", + "new", fullname, + "old", en->name()); + LegacyReadOnlyGenerateClassFile(file, en, options, generator_context); + } } void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, @@ -1539,6 +1588,19 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, LegacyGenerateClassFile(file, message, options, generator_context); } + // Write legacy file for backwards compatibility with "readonly" keywword + std::string lower = message->name(); + std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower); + if (lower == "readonly") { + printer.Print( + "// Adding a class alias for backwards compatibility with the \"readonly\" keyword.\n"); + printer.Print( + "class_alias(^new^::class, __NAMESPACE__ . '\\^old^');\n\n", + "new", fullname, + "old", message->name()); + LegacyReadOnlyGenerateClassFile(file, message, options, generator_context); + } + // Nested messages and enums. for (int i = 0; i < message->nested_type_count(); i++) { GenerateMessageFile(file, message->nested_type(i), options, From 7ed2c262e26746b85104e318b534e04325967653 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 31 May 2022 15:19:28 -0700 Subject: [PATCH 02/31] feat: [PHP] add previous classname to descriptor pool --- php/composer.json | 5 +- php/ext/google/protobuf/def.c | 18 +++++-- php/ext/google/protobuf/names.c | 38 +++++++++++---- php/ext/google/protobuf/names.h | 2 +- php/ext/google/protobuf/protobuf.c | 9 +++- .../Google/Protobuf/Internal/Descriptor.php | 16 ++++++- .../Protobuf/Internal/DescriptorPool.php | 1 + .../Protobuf/Internal/EnumDescriptor.php | 3 +- php/src/Google/Protobuf/Internal/GPBUtil.php | 47 ++++++++++++++++++- php/tests/PreviouslyGeneratedClassTest.php | 18 +++++++ .../TestPreviouslyUnreservedMessage.php | 28 +++++++++++ .../generated_previous/Previous/readonly.php | 31 ++++++++++++ .../test_previously_unreserved_message.proto | 5 ++ 13 files changed, 199 insertions(+), 22 deletions(-) create mode 100644 php/tests/PreviouslyGeneratedClassTest.php create mode 100644 php/tests/generated_previous/GPBMetadata/ProtoPrevious/TestPreviouslyUnreservedMessage.php create mode 100644 php/tests/generated_previous/Previous/readonly.php create mode 100644 php/tests/proto_previous/test_previously_unreserved_message.proto diff --git a/php/composer.json b/php/composer.json index f712f0ebb9d63..001a120023eb4 100644 --- a/php/composer.json +++ b/php/composer.json @@ -20,7 +20,10 @@ "autoload-dev": { "psr-4": { "": "tmp" - } + }, + "classmap": [ + "tests/generated_previous" + ] }, "scripts": { "test_c": "./generate_test_protos.sh && ./tests/compile_extension.sh && php -dextension=ext/google/protobuf/modules/protobuf.so vendor/bin/phpunit --bootstrap tests/force_c_ext.php tests", diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index dfb96f283f696..8be2b92c51da3 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -162,7 +162,7 @@ static void EnumDescriptor_FromEnumDef(zval *val, const upb_EnumDef *m) { ZVAL_NULL(val); } else { char *classname = - GetPhpClassname(upb_EnumDef_File(m), upb_EnumDef_FullName(m)); + GetPhpClassname(upb_EnumDef_File(m), upb_EnumDef_FullName(m), false); zend_string *str = zend_string_init(classname, strlen(classname), 0); zend_class_entry *ce = zend_lookup_class(str); // May autoload the class. @@ -500,14 +500,22 @@ static void Descriptor_destructor(zend_object* obj) { static zend_class_entry *Descriptor_GetGeneratedClass(const upb_MessageDef *m) { char *classname = - GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m)); + GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), false); zend_string *str = zend_string_init(classname, strlen(classname), 0); zend_class_entry *ce = zend_lookup_class(str); // May autoload the class. - zend_string_release (str); - if (!ce) { - zend_error(E_ERROR, "Couldn't load generated class %s", classname); + char *classname2 = + GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), true); + str = zend_string_init(classname2, strlen(classname2), 0); + ce = zend_lookup_class(str); // May autoload the class. + + zend_string_release (str); + free(classname2); + + if (!ce) { + zend_error(E_ERROR, "Couldn't load generated class %s", classname); + } } free(classname); diff --git a/php/ext/google/protobuf/names.c b/php/ext/google/protobuf/names.c index a2988816ed0dc..b304d92310dc2 100644 --- a/php/ext/google/protobuf/names.c +++ b/php/ext/google/protobuf/names.c @@ -89,6 +89,9 @@ const char *const kReservedNames[] = { "string", "true", "false", "null", "void", "iterable", NULL}; +const char *const kPreviouslyUnreservedNames[] = { + "readonly", NULL}; + bool is_reserved_name(const char* name) { int i; for (i = 0; kReservedNames[i]; i++) { @@ -99,6 +102,16 @@ bool is_reserved_name(const char* name) { return false; } +bool is_previously_unreserved_name(const char* name) { + int i; + for (i = 0; kPreviouslyUnreservedNames[i]; i++) { + if (strcmp(kPreviouslyUnreservedNames[i], name) == 0) { + return true; + } + } + return false; +} + static char nolocale_tolower(char ch) { if (ch >= 'A' && ch <= 'Z') { return ch - ('A' - 'a'); @@ -115,7 +128,7 @@ static char nolocale_toupper(char ch) { } } -static bool is_reserved(const char *segment, int length) { +static bool is_reserved(const char *segment, int length, bool previous) { bool result; char* lower = calloc(1, length + 1); memcpy(lower, segment, length); @@ -126,6 +139,9 @@ static bool is_reserved(const char *segment, int length) { } lower[length] = 0; result = is_reserved_name(lower); + if (result && previous && is_previously_unreserved_name(lower)) { + result = false; + } free(lower); return result; } @@ -133,11 +149,12 @@ static bool is_reserved(const char *segment, int length) { static void fill_prefix(const char *segment, int length, const char *prefix_given, const char *package_name, - stringsink *classname) { + stringsink *classname, + bool previous) { if (prefix_given != NULL && strcmp(prefix_given, "") != 0) { stringsink_string(classname, prefix_given, strlen(prefix_given)); } else { - if (is_reserved(segment, length)) { + if (is_reserved(segment, length, previous)) { if (package_name != NULL && strcmp("google.protobuf", package_name) == 0) { stringsink_string(classname, "GPB", 3); @@ -160,7 +177,7 @@ static void fill_segment(const char *segment, int length, } static void fill_namespace(const char *package, const char *php_namespace, - stringsink *classname) { + stringsink *classname, bool previous) { if (php_namespace != NULL) { if (strlen(php_namespace) != 0) { stringsink_string(classname, php_namespace, strlen(php_namespace)); @@ -174,7 +191,7 @@ static void fill_namespace(const char *package, const char *php_namespace, while (j < package_len && package[j] != '.') { j++; } - fill_prefix(package + i, j - i, "", package, classname); + fill_prefix(package + i, j - i, "", package, classname, previous); fill_segment(package + i, j - i, classname, true); stringsink_string(classname, "\\", 1); i = j + 1; @@ -185,7 +202,8 @@ static void fill_namespace(const char *package, const char *php_namespace, static void fill_classname(const char *fullname, const char *package, const char *prefix, - stringsink *classname) { + stringsink *classname, + bool previous) { int classname_start = 0; if (package != NULL) { size_t package_len = strlen(package); @@ -199,7 +217,7 @@ static void fill_classname(const char *fullname, while (j < fullname_len && fullname[j] != '.') { j++; } - fill_prefix(fullname + i, j - i, prefix, package, classname); + fill_prefix(fullname + i, j - i, prefix, package, classname, previous); fill_segment(fullname + i, j - i, classname, false); if (j != fullname_len) { stringsink_string(classname, "\\", 1); @@ -215,7 +233,7 @@ char *str_view_dup(upb_StringView str) { return ret; } -char *GetPhpClassname(const upb_FileDef *file, const char *fullname) { +char *GetPhpClassname(const upb_FileDef *file, const char *fullname, bool previous) { // Prepend '.' to package name to make it absolute. In the 5 additional // bytes allocated, one for '.', one for trailing 0, and 3 for 'GPB' if // given message is google.protobuf.Empty. @@ -234,8 +252,8 @@ char *GetPhpClassname(const upb_FileDef *file, const char *fullname) { stringsink namesink; stringsink_init(&namesink); - fill_namespace(package, php_namespace, &namesink); - fill_classname(fullname, package, prefix, &namesink); + fill_namespace(package, php_namespace, &namesink, previous); + fill_classname(fullname, package, prefix, &namesink, previous); stringsink_string(&namesink, "\0", 1); ret = strdup(namesink.ptr); stringsink_uninit(&namesink); diff --git a/php/ext/google/protobuf/names.h b/php/ext/google/protobuf/names.h index 86af799ac0c24..52911c319e3b4 100644 --- a/php/ext/google/protobuf/names.h +++ b/php/ext/google/protobuf/names.h @@ -35,6 +35,6 @@ // Translates a protobuf symbol name (eg. foo.bar.Baz) into a PHP class name // (eg. \Foo\Bar\Baz). -char *GetPhpClassname(const upb_FileDef *file, const char *fullname); +char *GetPhpClassname(const upb_FileDef *file, const char *fullname, bool previous); #endif // PHP_PROTOBUF_NAMES_H_ diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index c786b6eca0103..268108654a21c 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -242,13 +242,18 @@ bool ObjCache_Get(const void *upb_obj, zval *val) { // ----------------------------------------------------------------------------- void NameMap_AddMessage(const upb_MessageDef *m) { - char *k = GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m)); + char *k = GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), false); zend_hash_str_add_ptr(&PROTOBUF_G(name_msg_cache), k, strlen(k), (void*)m); + char *k2 = GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), true); + if (strcmp(k, k2) != 0) { + zend_hash_str_add_ptr(&PROTOBUF_G(name_msg_cache), k2, strlen(k2), (void*)m); + } free(k); + free(k2); } void NameMap_AddEnum(const upb_EnumDef *e) { - char *k = GetPhpClassname(upb_EnumDef_File(e), upb_EnumDef_FullName(e)); + char *k = GetPhpClassname(upb_EnumDef_File(e), upb_EnumDef_FullName(e), false); zend_hash_str_add_ptr(&PROTOBUF_G(name_enum_cache), k, strlen(k), (void*)e); free(k); } diff --git a/php/src/Google/Protobuf/Internal/Descriptor.php b/php/src/Google/Protobuf/Internal/Descriptor.php index a7f80d534e01e..b7d59cbf9b4b2 100644 --- a/php/src/Google/Protobuf/Internal/Descriptor.php +++ b/php/src/Google/Protobuf/Internal/Descriptor.php @@ -45,6 +45,7 @@ class Descriptor private $enum_type = []; private $klass; private $legacy_klass; + private $previous_klass; private $options; private $oneof_decl = []; @@ -162,6 +163,16 @@ public function getLegacyClass() return $this->legacy_klass; } + public function setPreviouslyReservedClass($klass) + { + $this->previous_klass = $klass; + } + + public function getPreviouslyReservedClass() + { + return $this->previous_klass; + } + public function setOptions($options) { $this->options = $options; @@ -179,6 +190,7 @@ public static function buildFromProto($proto, $file_proto, $containing) $message_name_without_package = ""; $classname = ""; $legacy_classname = ""; + $previous_classname = ""; $fullname = ""; GPBUtil::getFullClassName( $proto, @@ -187,10 +199,12 @@ public static function buildFromProto($proto, $file_proto, $containing) $message_name_without_package, $classname, $legacy_classname, - $fullname); + $fullname, + $previous_classname); $desc->setFullName($fullname); $desc->setClass($classname); $desc->setLegacyClass($legacy_classname); + $desc->setPreviouslyReservedClass($previous_classname); $desc->setOptions($proto->getOptions()); foreach ($proto->getField() as $field_proto) { diff --git a/php/src/Google/Protobuf/Internal/DescriptorPool.php b/php/src/Google/Protobuf/Internal/DescriptorPool.php index 1468a02380d9e..9709a1c80e90b 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorPool.php +++ b/php/src/Google/Protobuf/Internal/DescriptorPool.php @@ -96,6 +96,7 @@ public function addDescriptor($descriptor) $descriptor->getClass(); $this->class_to_desc[$descriptor->getClass()] = $descriptor; $this->class_to_desc[$descriptor->getLegacyClass()] = $descriptor; + $this->class_to_desc[$descriptor->getPreviouslyReservedClass()] = $descriptor; foreach ($descriptor->getNestedType() as $nested_type) { $this->addDescriptor($nested_type); } diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptor.php b/php/src/Google/Protobuf/Internal/EnumDescriptor.php index 7af4f84012e59..383f53b13fa06 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptor.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptor.php @@ -101,7 +101,8 @@ public static function buildFromProto($proto, $file_proto, $containing) $enum_name_without_package, $classname, $legacy_classname, - $fullname); + $fullname, + $unused_previous_classname); $desc->setFullName($fullname); $desc->setClass($classname); $desc->setLegacyClass($legacy_classname); diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php index d7f2faaf6c580..0e5cd2a7e6dee 100644 --- a/php/src/Google/Protobuf/Internal/GPBUtil.php +++ b/php/src/Google/Protobuf/Internal/GPBUtil.php @@ -304,6 +304,27 @@ public static function getClassNamePrefix( return ""; } + public static function getPreviouslyUnreservedClassNamePrefix( + $classname, + $file_proto) + { + $previously_unreserved_words = array( + "readonly"=>0 + ); + + if (array_key_exists(strtolower($classname), $previously_unreserved_words)) { + $option = $file_proto->getOptions(); + $prefix = is_null($option) ? "" : $option->getPhpClassPrefix(); + if ($prefix !== "") { + return $prefix; + } + + return ""; + } + + return self::getClassNamePrefix($classname, $file_proto); + } + public static function getLegacyClassNameWithoutPackage( $name, $file_proto) @@ -323,6 +344,17 @@ public static function getClassNameWithoutPackage( return implode('\\', $parts); } + public static function getPreviouslyUnreservedClassNameWithoutPackage( + $name, + $file_proto) + { + $parts = explode('.', $name); + foreach ($parts as $i => $part) { + $parts[$i] = static::getPreviouslyUnreservedClassNamePrefix($parts[$i], $file_proto) . $parts[$i]; + } + return implode('\\', $parts); + } + public static function getFullClassName( $proto, $containing, @@ -330,7 +362,8 @@ public static function getFullClassName( &$message_name_without_package, &$classname, &$legacy_classname, - &$fullname) + &$fullname, + &$previous_classname) { // Full name needs to start with '.'. $message_name_without_package = $proto->getName(); @@ -351,6 +384,9 @@ public static function getFullClassName( $legacy_class_name_without_package = static::getLegacyClassNameWithoutPackage( $message_name_without_package, $file_proto); + $previous_class_name_without_package = + static::getPreviouslyUnreservedClassNameWithoutPackage( + $message_name_without_package, $file_proto); $option = $file_proto->getOptions(); if (!is_null($option) && $option->hasPhpNamespace()) { @@ -359,10 +395,13 @@ public static function getFullClassName( $classname = $namespace . "\\" . $class_name_without_package; $legacy_classname = $namespace . "\\" . $legacy_class_name_without_package; + $previous_classname = + $namespace . "\\" . $previous_class_name_without_package; return; } else { $classname = $class_name_without_package; $legacy_classname = $legacy_class_name_without_package; + $previous_classname = $previous_class_name_without_package; return; } } @@ -370,6 +409,7 @@ public static function getFullClassName( if ($package === "") { $classname = $class_name_without_package; $legacy_classname = $legacy_class_name_without_package; + $previous_classname = $previous_class_name_without_package; } else { $parts = array_map('ucwords', explode('.', $package)); foreach ($parts as $i => $part) { @@ -382,6 +422,11 @@ public static function getFullClassName( $legacy_classname = implode('\\', array_map('ucwords', explode('.', $package))). "\\".$legacy_class_name_without_package; + $previous_classname = + implode('\\', array_map('ucwords', explode('.', $package))). + "\\".self::getPreviouslyUnreservedClassNamePrefix( + $previous_class_name_without_package, $file_proto). + $previous_class_name_without_package; } } diff --git a/php/tests/PreviouslyGeneratedClassTest.php b/php/tests/PreviouslyGeneratedClassTest.php new file mode 100644 index 0000000000000..077c84ff1359c --- /dev/null +++ b/php/tests/PreviouslyGeneratedClassTest.php @@ -0,0 +1,18 @@ +assertTrue(true); + } +} diff --git a/php/tests/generated_previous/GPBMetadata/ProtoPrevious/TestPreviouslyUnreservedMessage.php b/php/tests/generated_previous/GPBMetadata/ProtoPrevious/TestPreviouslyUnreservedMessage.php new file mode 100644 index 0000000000000..d2120f9b6b4d1 --- /dev/null +++ b/php/tests/generated_previous/GPBMetadata/ProtoPrevious/TestPreviouslyUnreservedMessage.php @@ -0,0 +1,28 @@ +internalAddGeneratedFile( + ' +W +7proto_previous/test_previously_unreserved_message.protoprevious" + +readonlybproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/php/tests/generated_previous/Previous/readonly.php b/php/tests/generated_previous/Previous/readonly.php new file mode 100644 index 0000000000000..013f29354c8c2 --- /dev/null +++ b/php/tests/generated_previous/Previous/readonly.php @@ -0,0 +1,31 @@ +previous.readonly + */ +class readonly extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\ProtoPrevious\TestPreviouslyUnreservedMessage::initOnce(); + parent::__construct($data); + } + +} + diff --git a/php/tests/proto_previous/test_previously_unreserved_message.proto b/php/tests/proto_previous/test_previously_unreserved_message.proto new file mode 100644 index 0000000000000..1b4b0b7978e20 --- /dev/null +++ b/php/tests/proto_previous/test_previously_unreserved_message.proto @@ -0,0 +1,5 @@ +syntax = "proto3"; + +package previous; + +message readonly {} \ No newline at end of file From 8b4837981c3f1f1bd8633d253adeceda6a116c29 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 1 Jun 2022 08:51:12 -0700 Subject: [PATCH 03/31] refactor for efficiency --- php/ext/google/protobuf/names.c | 29 +++++++++++++++++++++++++++++ php/ext/google/protobuf/names.h | 1 + php/ext/google/protobuf/protobuf.c | 6 +++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/php/ext/google/protobuf/names.c b/php/ext/google/protobuf/names.c index b304d92310dc2..212aded35b716 100644 --- a/php/ext/google/protobuf/names.c +++ b/php/ext/google/protobuf/names.c @@ -261,3 +261,32 @@ char *GetPhpClassname(const upb_FileDef *file, const char *fullname, bool previo free(prefix); return ret; } + +bool IsPreviouslyUnreservedClassName(const char* fullname) { + const char *classname = strrchr(fullname, '\\'); + if (classname) { + classname += 1; + } else { + classname = fullname; + } + if (strncmp(classname, "PB", 2) != 0) { + return false; + } + classname += 2; + int length = strlen(classname); + char* lower = calloc(1, length + 1); + memcpy(lower, classname, length); + int i = 0; + while(lower[i]) { + lower[i] = nolocale_tolower(lower[i]); + i++; + } + lower[length] = 0; + int j; + for (j = 0; kPreviouslyUnreservedNames[j]; j++) { + if (strcmp(kPreviouslyUnreservedNames[j], lower) == 0) { + return true; + } + } + return false; +} diff --git a/php/ext/google/protobuf/names.h b/php/ext/google/protobuf/names.h index 52911c319e3b4..cc42dc85a0d57 100644 --- a/php/ext/google/protobuf/names.h +++ b/php/ext/google/protobuf/names.h @@ -36,5 +36,6 @@ // Translates a protobuf symbol name (eg. foo.bar.Baz) into a PHP class name // (eg. \Foo\Bar\Baz). char *GetPhpClassname(const upb_FileDef *file, const char *fullname, bool previous); +bool IsPreviouslyUnreservedClassName(const char* fullname); #endif // PHP_PROTOBUF_NAMES_H_ diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index 268108654a21c..608ba5f12f977 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -244,12 +244,12 @@ bool ObjCache_Get(const void *upb_obj, zval *val) { void NameMap_AddMessage(const upb_MessageDef *m) { char *k = GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), false); zend_hash_str_add_ptr(&PROTOBUF_G(name_msg_cache), k, strlen(k), (void*)m); - char *k2 = GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), true); - if (strcmp(k, k2) != 0) { + if (IsPreviouslyUnreservedClassName(k)) { + char *k2 = GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), true); zend_hash_str_add_ptr(&PROTOBUF_G(name_msg_cache), k2, strlen(k2), (void*)m); + free(k2); } free(k); - free(k2); } void NameMap_AddEnum(const upb_EnumDef *e) { From c8fa2f11685049acfba5b831cbf80e040eb3b5a9 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Thu, 2 Jun 2022 08:55:17 -0700 Subject: [PATCH 04/31] free lower --- php/ext/google/protobuf/names.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/php/ext/google/protobuf/names.c b/php/ext/google/protobuf/names.c index 212aded35b716..87ac40de76b13 100644 --- a/php/ext/google/protobuf/names.c +++ b/php/ext/google/protobuf/names.c @@ -285,8 +285,10 @@ bool IsPreviouslyUnreservedClassName(const char* fullname) { int j; for (j = 0; kPreviouslyUnreservedNames[j]; j++) { if (strcmp(kPreviouslyUnreservedNames[j], lower) == 0) { + free(lower); return true; } } + free(lower); return false; } From ecd1476f4ae7499f906c1aef082b95cac79a0cd4 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 6 Jun 2022 18:36:26 +0000 Subject: [PATCH 05/31] fix valgrind error --- php/ext/google/protobuf/def.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index 8be2b92c51da3..ae22338702f55 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -504,13 +504,15 @@ static zend_class_entry *Descriptor_GetGeneratedClass(const upb_MessageDef *m) { zend_string *str = zend_string_init(classname, strlen(classname), 0); zend_class_entry *ce = zend_lookup_class(str); // May autoload the class. + zend_string_release (str); + if (!ce) { char *classname2 = GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), true); - str = zend_string_init(classname2, strlen(classname2), 0); - ce = zend_lookup_class(str); // May autoload the class. + zend_string *str2 = zend_string_init(classname2, strlen(classname2), 0); + ce = zend_lookup_class(str2); // May autoload the class. - zend_string_release (str); + zend_string_release (str2); free(classname2); if (!ce) { From 226dd65989fa8bda6db3cff9030b4c03ecc1a6f9 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Wed, 8 Jun 2022 22:18:57 +0200 Subject: [PATCH 06/31] Make //:protobuf_python and //:well_known_types_py_pb2 public. These targets form the public interface of the Python protocol buffer support and must always be public. It looks like commit a6901f057e43b3b5c8079a5dac6165c5a8e9d427 accidentally restricted their visibility. --- BUILD.bazel | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BUILD.bazel b/BUILD.bazel index 6017730f06aa8..02b3855e7ff88 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -929,7 +929,7 @@ py_proto_library( default_runtime = "", protoc = ":protoc", srcs_version = "PY2AND3", - visibility = ["@upb//:__subpackages__"], + visibility = ["//visibility:public"], ) py_library( @@ -941,6 +941,7 @@ py_library( ":python/google/protobuf/pyext/_message.so", ], }), + visibility = ["//visibility:public"], deps = [ ":python_srcs", ":well_known_types_py_pb2", From 5f8e6dff2a9c2ca5810bb3008ae357d826d19006 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Thu, 9 Jun 2022 10:23:55 -0700 Subject: [PATCH 07/31] fix dist tests --- Makefile.am | 4 ++++ php/BUILD.bazel | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Makefile.am b/Makefile.am index cb52f3791118a..4c7c7111d4700 100644 --- a/Makefile.am +++ b/Makefile.am @@ -958,6 +958,8 @@ php_EXTRA_DIST= \ php/tests/EncodeDecodeTest.php \ php/tests/force_c_ext.php \ php/tests/gdb_test.sh \ + php/tests/generated_previous/GPBMetadata/ProtoPrevious/TestPreviouslyUnreservedMessage.php \ + php/tests/generated_previous/Previous/readonly.php \ php/tests/GeneratedClassTest.php \ php/tests/GeneratedPhpdocTest.php \ php/tests/GeneratedServiceTest.php \ @@ -967,6 +969,7 @@ php_EXTRA_DIST= \ php/tests/multirequest.php \ php/tests/multirequest.sh \ php/tests/PhpImplementationTest.php \ + php/tests/PreviouslyGeneratedClassTest.php \ php/tests/proto/empty/echo.proto \ php/tests/proto/test.proto \ php/tests/proto/test_descriptors.proto \ @@ -985,6 +988,7 @@ php_EXTRA_DIST= \ php/tests/proto/test_service.proto \ php/tests/proto/test_service_namespace.proto \ php/tests/proto/test_wrapper_type_setters.proto \ + php/tests/proto_previous/test_previously_unreserved_message.proto \ php/tests/test_base.php \ php/tests/test_util.php \ php/tests/valgrind.supp \ diff --git a/php/BUILD.bazel b/php/BUILD.bazel index 346095957452f..dfb0976fcadbb 100644 --- a/php/BUILD.bazel +++ b/php/BUILD.bazel @@ -12,7 +12,9 @@ pkg_files( "src/Google/Protobuf/**/*.php", "tests/*.php", "tests/*.sh", + "tests/generated_previous/**/*.php", "tests/proto/**/*.proto", + "tests/proto_previous/*.proto", ]) + [ "BUILD.bazel", "README.md", From 39996cfa128983f540923ba93ce02c9420596542 Mon Sep 17 00:00:00 2001 From: theodorerose Date: Wed, 22 Jun 2022 22:17:58 +0000 Subject: [PATCH 08/31] cherry-pick: arenastring --- src/google/protobuf/arena_impl.h | 21 ++++++++++++++------- src/google/protobuf/arenastring.cc | 6 ++---- src/google/protobuf/arenastring.h | 27 +++++++++++++++++---------- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/google/protobuf/arena_impl.h b/src/google/protobuf/arena_impl.h index d02ad93985ed5..76727688b5583 100644 --- a/src/google/protobuf/arena_impl.h +++ b/src/google/protobuf/arena_impl.h @@ -55,6 +55,13 @@ namespace google { namespace protobuf { namespace internal { +// To prevent sharing cache lines between threads +#ifdef __cpp_aligned_new +enum { kCacheAlignment = 64 }; +#else +enum { kCacheAlignment = alignof(max_align_t) }; // do the best we can +#endif + inline constexpr size_t AlignUpTo8(size_t n) { // Align n to next multiple of 8 (from Hacker's Delight, Chapter 3.) return (n + 7) & static_cast(-8); @@ -497,10 +504,10 @@ class PROTOBUF_EXPORT ThreadSafeArena { // have fallback function calls in tail position. This substantially improves // code for the happy path. PROTOBUF_NDEBUG_INLINE bool MaybeAllocateAligned(size_t n, void** out) { - SerialArena* a; + SerialArena* arena; if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() && - GetSerialArenaFromThreadCache(&a))) { - return a->MaybeAllocateAligned(n, out); + GetSerialArenaFromThreadCache(&arena))) { + return arena->MaybeAllocateAligned(n, out); } return false; } @@ -564,7 +571,7 @@ class PROTOBUF_EXPORT ThreadSafeArena { // fast path optimizes the case where a single thread uses multiple arenas. ThreadCache* tc = &thread_cache(); SerialArena* serial = hint_.load(std::memory_order_acquire); - if (PROTOBUF_PREDICT_TRUE(serial != NULL && serial->owner() == tc)) { + if (PROTOBUF_PREDICT_TRUE(serial != nullptr && serial->owner() == tc)) { *arena = serial; return true; } @@ -602,7 +609,7 @@ class PROTOBUF_EXPORT ThreadSafeArena { #ifdef _MSC_VER #pragma warning(disable : 4324) #endif - struct alignas(64) ThreadCache { + struct alignas(kCacheAlignment) ThreadCache { #if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL) // If we are using the ThreadLocalStorage class to store the ThreadCache, // then the ThreadCache's default constructor has to be responsible for @@ -610,7 +617,7 @@ class PROTOBUF_EXPORT ThreadSafeArena { ThreadCache() : next_lifecycle_id(0), last_lifecycle_id_seen(-1), - last_serial_arena(NULL) {} + last_serial_arena(nullptr) {} #endif // Number of per-thread lifecycle IDs to reserve. Must be power of two. @@ -633,7 +640,7 @@ class PROTOBUF_EXPORT ThreadSafeArena { #ifdef _MSC_VER #pragma warning(disable : 4324) #endif - struct alignas(64) CacheAlignedLifecycleIdGenerator { + struct alignas(kCacheAlignment) CacheAlignedLifecycleIdGenerator { std::atomic id; }; static CacheAlignedLifecycleIdGenerator lifecycle_id_generator_; diff --git a/src/google/protobuf/arenastring.cc b/src/google/protobuf/arenastring.cc index d886ddad66a5c..3887c940a3e15 100644 --- a/src/google/protobuf/arenastring.cc +++ b/src/google/protobuf/arenastring.cc @@ -187,7 +187,7 @@ std::string* ArenaStringPtr::Release() { if (IsDefault()) return nullptr; std::string* released = tagged_ptr_.Get(); - if (!tagged_ptr_.IsAllocated()) { + if (tagged_ptr_.IsArena()) { released = tagged_ptr_.IsMutable() ? new std::string(std::move(*released)) : new std::string(*released); } @@ -216,9 +216,7 @@ void ArenaStringPtr::SetAllocated(std::string* value, Arena* arena) { } void ArenaStringPtr::Destroy() { - if (tagged_ptr_.IsAllocated()) { - delete tagged_ptr_.Get(); - } + delete tagged_ptr_.GetIfAllocated(); } void ArenaStringPtr::ClearToEmpty() { diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index b8d31fec015b0..6bc8395f233f1 100644 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -96,13 +96,12 @@ class PROTOBUF_EXPORT LazyString { class TaggedStringPtr { public: - // Bit flags qualifying string properties. We can use up to 3 bits as - // ptr_ is guaranteed and enforced to be aligned on 8 byte boundaries. + // Bit flags qualifying string properties. We can use 2 bits as + // ptr_ is guaranteed and enforced to be aligned on 4 byte boundaries. enum Flags { kArenaBit = 0x1, // ptr is arena allocated - kAllocatedBit = 0x2, // ptr is heap allocated - kMutableBit = 0x4, // ptr contents are fully mutable - kMask = 0x7 // Bit mask + kMutableBit = 0x2, // ptr contents are fully mutable + kMask = 0x3 // Bit mask }; // Composed logical types @@ -112,7 +111,7 @@ class TaggedStringPtr { // Allocated strings are mutable and (as the name implies) owned. // A heap allocated string must be deleted. - kAllocated = kAllocatedBit | kMutableBit, + kAllocated = kMutableBit, // Mutable arena strings are strings where the string instance is owned // by the arena, but the string contents itself are owned by the string @@ -166,8 +165,16 @@ class TaggedStringPtr { // Returns true if the current string is an immutable default value. inline bool IsDefault() const { return (as_int() & kMask) == kDefault; } - // Returns true if the current string is a heap allocated mutable value. - inline bool IsAllocated() const { return as_int() & kAllocatedBit; } + // If the current string is a heap-allocated mutable value, returns a pointer + // to it. Returns nullptr otherwise. + inline std::string *GetIfAllocated() const { + auto allocated = as_int() ^ kAllocated; + if (allocated & kMask) return nullptr; + + auto ptr = reinterpret_cast(allocated); + PROTOBUF_ASSUME(ptr != nullptr); + return ptr; + } // Returns true if the current string is an arena allocated value. // This means it's either a mutable or fixed size arena string. @@ -224,8 +231,8 @@ static_assert(std::is_trivial::value, // Because ArenaStringPtr is used in oneof unions, its constructor is a NOP and // the field is always manually initialized via method calls. // -// See TaggedPtr for more information about the types of string values being -// held, and the mutable and ownership invariants for each type. +// See TaggedStringPtr for more information about the types of string values +// being held, and the mutable and ownership invariants for each type. struct PROTOBUF_EXPORT ArenaStringPtr { ArenaStringPtr() = default; constexpr ArenaStringPtr(ExplicitlyConstructedArenaString* default_value, From 71adb837e7aa4c2405b6a9481257198d9b4217b6 Mon Sep 17 00:00:00 2001 From: theodorerose Date: Wed, 22 Jun 2022 22:26:53 +0000 Subject: [PATCH 09/31] cherry-pick c38281dd20e562bac239bc77ab2fa10f71661708 --- php/src/Google/Protobuf/FieldDescriptor.php | 35 +++++++++++++---- .../Protobuf/Internal/FieldDescriptor.php | 38 +++++++++++++++++-- .../Protobuf/Internal/OneofDescriptor.php | 9 +++++ php/src/Google/Protobuf/OneofDescriptor.php | 9 ++++- 4 files changed, 79 insertions(+), 12 deletions(-) diff --git a/php/src/Google/Protobuf/FieldDescriptor.php b/php/src/Google/Protobuf/FieldDescriptor.php index 6d08cea9da975..ac919a24a97bc 100644 --- a/php/src/Google/Protobuf/FieldDescriptor.php +++ b/php/src/Google/Protobuf/FieldDescriptor.php @@ -39,6 +39,7 @@ class FieldDescriptor { use GetPublicDescriptorTrait; + /** @var \Google\Protobuf\Internal\FieldDescriptor $internal_desc */ private $internal_desc; /** @@ -81,6 +82,32 @@ public function getType() return $this->internal_desc->getType(); } + /** + * @return OneofDescriptor + */ + public function getContainingOneof() + { + return $this->getPublicDescriptor($this->internal_desc->getContainingOneof()); + } + + /** + * Gets the field's containing oneof, only if non-synthetic. + * + * @return null|OneofDescriptor + */ + public function getRealContainingOneof() + { + return $this->getPublicDescriptor($this->internal_desc->getRealContainingOneof()); + } + + /** + * @return boolean + */ + public function hasOptionalKeyword() + { + return $this->internal_desc->hasOptionalKeyword(); + } + /** * @return Descriptor Returns a descriptor for the field type if the field type is a message, otherwise throws \Exception * @throws \Exception @@ -114,12 +141,4 @@ public function isMap() { return $this->internal_desc->isMap(); } - - /** - * @return boolean - */ - public function hasOptionalKeyword() - { - return $this->internal_desc->hasOptionalKeyword(); - } } diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptor.php b/php/src/Google/Protobuf/Internal/FieldDescriptor.php index ce83f63a2b267..3a9a73b729ff9 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptor.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptor.php @@ -46,8 +46,11 @@ class FieldDescriptor private $message_type; private $enum_type; private $packed; - private $is_map; private $oneof_index = -1; + private $proto3_optional; + + /** @var OneofDescriptor $containing_oneof */ + private $containing_oneof; public function __construct() { @@ -169,6 +172,32 @@ public function getPacked() return $this->packed; } + public function getProto3Optional() + { + return $this->proto3_optional; + } + + public function setProto3Optional($proto3_optional) + { + $this->proto3_optional = $proto3_optional; + } + + public function getContainingOneof() + { + return $this->containing_oneof; + } + + public function setContainingOneof($containing_oneof) + { + $this->containing_oneof = $containing_oneof; + } + + public function getRealContainingOneof() + { + return !is_null($this->containing_oneof) && !$this->containing_oneof->isSynthetic() + ? $this->containing_oneof : null; + } + public function isPackable() { return $this->isRepeated() && self::isTypePackable($this->type); @@ -214,6 +243,10 @@ private static function isTypePackable($field_type) $field_type !== GPBType::BYTES); } + /** + * @param FieldDescriptorProto $proto + * @return FieldDescriptor + */ public static function getFieldDescriptor($proto) { $type_name = null; @@ -248,8 +281,6 @@ public static function getFieldDescriptor($proto) $field = new FieldDescriptor(); $field->setName($proto->getName()); - $json_name = $proto->hasJsonName() ? $proto->getJsonName() : - lcfirst(implode('', array_map('ucwords', explode('_', $proto->getName())))); if ($proto->hasJsonName()) { $json_name = $proto->getJsonName(); } else { @@ -269,6 +300,7 @@ public static function getFieldDescriptor($proto) $field->setLabel($proto->getLabel()); $field->setPacked($packed); $field->setOneofIndex($oneof_index); + $field->setProto3Optional($proto->getProto3Optional()); // At this time, the message/enum type may have not been added to pool. // So we use the type name as place holder and will replace it with the diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptor.php b/php/src/Google/Protobuf/Internal/OneofDescriptor.php index 67b107f6a4b63..4323685710239 100644 --- a/php/src/Google/Protobuf/Internal/OneofDescriptor.php +++ b/php/src/Google/Protobuf/Internal/OneofDescriptor.php @@ -37,6 +37,7 @@ class OneofDescriptor use HasPublicDescriptorTrait; private $name; + /** @var \Google\Protobuf\FieldDescriptor[] $fields */ private $fields; public function __construct() @@ -64,13 +65,21 @@ public function getFields() return $this->fields; } + public function isSynthetic() + { + return !is_null($this->fields) && count($this->fields) === 1 + && $this->fields[0]->getProto3Optional(); + } + public static function buildFromProto($oneof_proto, $desc, $index) { $oneof = new OneofDescriptor(); $oneof->setName($oneof_proto->getName()); foreach ($desc->getField() as $field) { + /** @var FieldDescriptor $field */ if ($field->getOneofIndex() == $index) { $oneof->addField($field); + $field->setContainingOneof($oneof); } } return $oneof; diff --git a/php/src/Google/Protobuf/OneofDescriptor.php b/php/src/Google/Protobuf/OneofDescriptor.php index 92b4e279dac33..66ffbd5caf9d5 100644 --- a/php/src/Google/Protobuf/OneofDescriptor.php +++ b/php/src/Google/Protobuf/OneofDescriptor.php @@ -38,6 +38,7 @@ class OneofDescriptor { use GetPublicDescriptorTrait; + /** @var \Google\Protobuf\Internal\OneofDescriptor $internal_desc */ private $internal_desc; /** @@ -62,6 +63,12 @@ public function getName() */ public function getField($index) { + if ( + is_null($this->internal_desc->getFields()) + || !isset($this->internal_desc->getFields()[$index]) + ) { + return null; + } return $this->getPublicDescriptor($this->internal_desc->getFields()[$index]); } @@ -75,6 +82,6 @@ public function getFieldCount() public function isSynthetic() { - return $this->internal_desc->isSynthetic(); + return $this->internal_desc->isSynthetic(); } } From 839b18b1ba42639fedecfd751102afcc5736b5d4 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 23 Jun 2022 12:13:16 -0700 Subject: [PATCH 10/31] Updating version.json and repo version numbers to: 21.2 --- Protobuf-C++.podspec | 2 +- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/README.md | 6 ++--- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/kotlin-lite/pom.xml | 2 +- java/kotlin/pom.xml | 2 +- java/lite.md | 2 +- java/lite/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- php/ext/google/protobuf/package.xml | 23 +++++++++++++++---- php/ext/google/protobuf/protobuf.h | 2 +- protobuf_version.bzl | 6 ++--- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- ruby/pom.xml | 4 ++-- 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 +- version.json | 20 ++++++++-------- 37 files changed, 69 insertions(+), 54 deletions(-) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index f537be063a499..e34d3430dec20 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.21.1' + s.version = '3.21.2' s.summary = 'Protocol Buffers v3 runtime library for C++.' s.homepage = 'https://github.com/google/protobuf' s.license = 'BSD-3-Clause' diff --git a/Protobuf.podspec b/Protobuf.podspec index 6b2beda07eaf3..85f1dc6fa1338 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.21.1' + s.version = '3.21.2' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = 'BSD-3-Clause' diff --git a/configure.ac b/configure.ac index 55e606478ada4..c55a6a2c2f95c 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.21.1],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.21.2],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index d477bb1396125..ea0559770ea42 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.21.1 + 3.21.2 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/main/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index d3c18db7d06e6..5517b0030cfc3 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.21.1 + 3.21.2 7.2 Google Inc. diff --git a/java/README.md b/java/README.md index 20f4c9be7b076..7e71e667160f5 100644 --- a/java/README.md +++ b/java/README.md @@ -23,7 +23,7 @@ If you are using Maven, use the following: com.google.protobuf protobuf-java - 3.21.1 + 3.21.2 ``` @@ -37,7 +37,7 @@ protobuf-java-util package: com.google.protobuf protobuf-java-util - 3.21.1 + 3.21.2 ``` @@ -45,7 +45,7 @@ protobuf-java-util package: If you are using Gradle, add the following to your `build.gradle` file's dependencies: ``` - implementation 'com.google.protobuf:protobuf-java:3.21.1' + implementation 'com.google.protobuf:protobuf-java:3.21.2' ``` Again, be sure to check that the version number matches (or is newer than) the version number of protoc that you are using. diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 3813b32528351..b4c3465e11808 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.21.1 + 3.21.2 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index e32d0aa352662..845ff8856acfd 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.1 + 3.21.2 protobuf-java diff --git a/java/kotlin-lite/pom.xml b/java/kotlin-lite/pom.xml index 3585f3ae7d451..3fec5ec45960e 100644 --- a/java/kotlin-lite/pom.xml +++ b/java/kotlin-lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.1 + 3.21.2 protobuf-kotlin-lite diff --git a/java/kotlin/pom.xml b/java/kotlin/pom.xml index e7958767bf58c..43debafe5062c 100644 --- a/java/kotlin/pom.xml +++ b/java/kotlin/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.1 + 3.21.2 protobuf-kotlin diff --git a/java/lite.md b/java/lite.md index 1a5c951ba3330..1ad0019847912 100644 --- a/java/lite.md +++ b/java/lite.md @@ -29,7 +29,7 @@ protobuf Java Lite runtime. If you are using Maven, include the following: com.google.protobuf protobuf-javalite - 3.21.1 + 3.21.2 ``` diff --git a/java/lite/pom.xml b/java/lite/pom.xml index 8b1590ba82412..7c635ec33f12f 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.1 + 3.21.2 protobuf-javalite diff --git a/java/pom.xml b/java/pom.xml index 5776cfda91ac0..34475a455a66e 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.1 + 3.21.2 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index afc912b072435..53f90ce6dcd13 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.1 + 3.21.2 protobuf-java-util diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index 5ef108509a7be..bf3d90eb8688b 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,11 +10,11 @@ protobuf-opensource@google.com yes - 2022-05-27 - + 2022-06-23 + - 3.21.1 - 3.21.1 + 3.21.2 + 3.21.2 stable @@ -1343,5 +1343,20 @@ G A release. + + + 3.21.2 + 3.21.2 + + + stable + stable + + 2022-06-23 + + BSD-3-Clause + + + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 6488196ff70a1..c5dac329093df 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -127,7 +127,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.21.1" +#define PHP_PROTOBUF_VERSION "3.21.2" // ptr -> PHP object cache. This is a weak map that caches lazily-created // wrapper objects around upb types: diff --git a/protobuf_version.bzl b/protobuf_version.bzl index 81b068cd83702..b6c35f38aec73 100644 --- a/protobuf_version.bzl +++ b/protobuf_version.bzl @@ -1,3 +1,3 @@ -PROTOC_VERSION = '21.1' -PROTOBUF_JAVA_VERSION = '3.21.1' -PROTOBUF_PYTHON_VERSION = '4.21.1' +PROTOC_VERSION = '21.2' +PROTOBUF_JAVA_VERSION = '3.21.2' +PROTOBUF_PYTHON_VERSION = '4.21.2' diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index 06af961d8af38..bce8121b4666e 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.21.1 + 3.21.2 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 56781369c26ba..2c3e06cc1b92f 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__ = '4.21.1' +__version__ = '4.21.2' diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index cecc370dce398..e7aa377519ae2 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.21.1" + s.version = "3.21.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/ruby/pom.xml b/ruby/pom.xml index b861c39748717..f1bdbf1f1f063 100644 --- a/ruby/pom.xml +++ b/ruby/pom.xml @@ -9,7 +9,7 @@ com.google.protobuf.jruby protobuf-jruby - 3.21.1 + 3.21.2 Protocol Buffer JRuby native extension Protocol Buffers are a way of encoding structured data in an efficient yet @@ -76,7 +76,7 @@ com.google.protobuf protobuf-java-util - 3.21.1 + 3.21.2 org.jruby diff --git a/src/Makefile.am b/src/Makefile.am index 264d8ea44809b..ffbc36c6ac8f1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ else PTHREAD_DEF = endif -PROTOBUF_VERSION = 32:1:0 +PROTOBUF_VERSION = 32: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 6db2ab3d33ee2..2368446bba627 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 3021001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021002 < 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 a06f93012d460..ac805601aeaa3 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 3021001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021002 < 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 1c4b0f6c00558..fd7e835e430b0 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 3021001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021002 < 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 78df1d51243bd..72c8071ba2bd3 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 3021001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021002 < 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 73193eb115946..87729c4893b99 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 3021001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021002 < 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 f5c44b831336e..fdc398c3d900f 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 3021001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021002 < 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 f4f77070d0788..fd75b88acec5f 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 3021001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021002 < 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 d534411b630da..8858e1936826e 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -178,7 +178,7 @@ #ifdef PROTOBUF_VERSION #error PROTOBUF_VERSION was previously defined #endif -#define PROTOBUF_VERSION 3021001 +#define PROTOBUF_VERSION 3021002 #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 63204f789ae8e..fb2e29f2eafd6 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 3021001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021002 < 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 1372271768b4e..b026be358d5d8 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 3021001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021002 < 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 81fb427183a58..9d90305126cbc 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 3021001 +#define GOOGLE_PROTOBUF_VERSION 3021002 // 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 7c074c4f058b9..3b5a469b2e22a 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 3021001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021002 < 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 83439e9994e1b..bbc1265f8cc9d 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 3021001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021002 < 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 6f549dd97c653..72304a56d1996 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 3021001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021002 < 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/version.json b/version.json index bd420ea28a7f3..7e2cafea0d630 100644 --- a/version.json +++ b/version.json @@ -1,17 +1,17 @@ { "21.x": { - "protoc_version": "21.2-dev", + "protoc_version": "21.2", "lts": false, - "date": "2022-05-27", + "date": "2022-06-23", "languages": { - "cpp": "3.21.2-dev", - "csharp": "3.21.2-dev", - "java": "3.21.2-dev", - "javascript": "3.21.2-dev", - "objectivec": "3.21.2-dev", - "php": "3.21.2-dev", - "python": "4.21.2-dev", - "ruby": "3.21.2-dev" + "cpp": "3.21.2", + "csharp": "3.21.2", + "java": "3.21.2", + "javascript": "3.21.2", + "objectivec": "3.21.2", + "php": "3.21.2", + "python": "4.21.2", + "ruby": "3.21.2" } } } \ No newline at end of file From 9fdf21ee8e615b4b151473e90726754614397484 Mon Sep 17 00:00:00 2001 From: theodorerose Date: Mon, 27 Jun 2022 16:36:29 +0000 Subject: [PATCH 11/31] generate CHANGES, bump minors --- CHANGES.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 0528229cafa61..b80a596e9adc0 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ +2022-06-27 version 21.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby) + + 2022-05-27 version 21.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby) C++ From 2bf000fb699dc690c7d2c4149349982a51cf326f Mon Sep 17 00:00:00 2001 From: theodorerose Date: Mon, 27 Jun 2022 16:56:47 +0000 Subject: [PATCH 12/31] updated change log notes --- CHANGES.txt | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index b80a596e9adc0..6da3dbd1cb2f8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,16 +1,21 @@ 2022-06-27 version 21.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby) + C++ + * ArenaString improvements (fix alignment issue) + + PHP + * API changes for OneOf (#10102) 2022-05-27 version 21.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby) - + C++ - * cmake: Revert "Fix cmake install targets (#9822)" (#10060) + * cmake: Revert "Fix cmake install targets (#9822)" (#10060) * Remove Abseil dependency from CMake build (#10056) Python * Update python wheel metadata with more information incl. required python version (#10058) * Fix segmentation fault when instantiating field via repeated field assignment (#10066) - + 2022-05-25 version 21.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby) C++ @@ -1102,11 +1107,11 @@ mistakenly tagged at the wrong commit. 2020-02-14 version 3.11.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) - + C# * Fix latest ArgumentException for C# extensions (#7188) * Enforce recursion depth checking for unknown fields (#7210) - + Ruby * Fix wrappers with a zero value (#7195) * Fix JSON serialization of 0/empty-valued wrapper types (#7198) @@ -1119,13 +1124,13 @@ mistakenly tagged at the wrong commit. PHP * Refactored ulong to zend_ulong for php7.4 compatibility (#7147) * Call register_class before getClass from desc to fix segfault (#7077) - + 2019-12-10 version 3.11.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) PHP * Make c extension portable for php 7.4 (#6968) - + 2019-12-02 version 3.11.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) @@ -1201,7 +1206,7 @@ mistakenly tagged at the wrong commit. * Support 32 bit values for ProtoStreamObjectWriter to Struct. * Removed the internal-only header coded_stream_inl.h and the internal-only methods defined there. * Enforced no SWIG wrapping of descriptor_database.h (other headers already had this restriction). - * Implementation of the equivalent of the MOMI parser for serialization. This removes one of the two serialization routines, by making the fast array serialization routine completely general. SerializeToCodedStream can now be implemented in terms of the much much faster array serialization. The array serialization regresses slightly, but when array serialization is not possible this wins big. + * Implementation of the equivalent of the MOMI parser for serialization. This removes one of the two serialization routines, by making the fast array serialization routine completely general. SerializeToCodedStream can now be implemented in terms of the much much faster array serialization. The array serialization regresses slightly, but when array serialization is not possible this wins big. * Do not convert unknown field name to snake case to accurately report error. * Fix a UBSAN warnings. (#6333) * Add podspec for C++ (#6404) @@ -1235,7 +1240,7 @@ mistakenly tagged at the wrong commit. * Change the parameter types of binaryReaderFn in ExtensionFieldBinaryInfo to (number, ?, ?). * Create dates.ts and time_of_days.ts to mirror Java versions. This is a near-identical conversion of c.g.type.util.{Dates,TimeOfDays} respectively. * Migrate moneys to TypeScript. - + PHP * Fix incorrect leap day for Timestamp (#6696) * Initialize well known type values (#6713) @@ -1249,7 +1254,7 @@ mistakenly tagged at the wrong commit. * Optimization for layout_init() (#6547) * Fix for GC of Ruby map frames. (#6533) * Fixed leap year handling by reworking upb_mktime() -> upb_timegm(). (#6695) - + Objective C * Remove OSReadLittle* due to alignment requirements (#6678) * Don't use unions and instead use memcpy for the type swaps. (#6672) From d569d184b8d25c118f8f8550b7e367129e8ca20d Mon Sep 17 00:00:00 2001 From: Mike Kruskal <62662355+mkruskal-google@users.noreply.github.com> Date: Wed, 6 Jul 2022 10:40:57 -0700 Subject: [PATCH 13/31] Disabling broken mac php tests (#10219) --- kokoro/macos/php7.0_mac/build.sh | 3 ++- kokoro/macos/php7.3_mac/build.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kokoro/macos/php7.0_mac/build.sh b/kokoro/macos/php7.0_mac/build.sh index e5a37e30eee0d..c6717e071b7fd 100755 --- a/kokoro/macos/php7.0_mac/build.sh +++ b/kokoro/macos/php7.0_mac/build.sh @@ -8,4 +8,5 @@ cd $(dirname $0)/../../.. # Prepare worker environment to run tests source kokoro/macos/prepare_build_macos_rc -./tests.sh php7.0_mac +# TODO(mkruskal) Re-enable this once we can get a working PHP 7.0 installed. +#./tests.sh php7.0_mac diff --git a/kokoro/macos/php7.3_mac/build.sh b/kokoro/macos/php7.3_mac/build.sh index 2d2f679da2ca0..2688ddbf65f00 100755 --- a/kokoro/macos/php7.3_mac/build.sh +++ b/kokoro/macos/php7.3_mac/build.sh @@ -8,4 +8,5 @@ cd $(dirname $0)/../../.. # Prepare worker environment to run tests source kokoro/macos/prepare_build_macos_rc -./tests.sh php7.3_mac +# TODO(mkruskal) Re-enable this once we can get a working PHP 7.0 installed. +#./tests.sh php7.3_mac From 9c39cd23772b8cd5d6a48bb516298b14df5cb036 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Wed, 6 Jul 2022 22:34:42 +0000 Subject: [PATCH 14/31] Change composer download --- kokoro/linux/dockerfile/test/php_32bit/Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kokoro/linux/dockerfile/test/php_32bit/Dockerfile b/kokoro/linux/dockerfile/test/php_32bit/Dockerfile index d657af1649dd1..2fd620e1b2bd6 100644 --- a/kokoro/linux/dockerfile/test/php_32bit/Dockerfile +++ b/kokoro/linux/dockerfile/test/php_32bit/Dockerfile @@ -47,8 +47,10 @@ RUN cd /var/local \ && make install # Install composer -RUN curl -sS https://getcomposer.org/installer | php -RUN mv composer.phar /usr/local/bin/composer +RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +RUN php composer-setup.php +RUN mv composer.phar /usr/bin/composer +RUN php -r "unlink('composer-setup.php');" # Download php source code RUN git clone https://github.com/php/php-src From 75cc3a2af4693f14b27c7290d7f2148c77bce3d7 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Fri, 8 Jul 2022 16:15:02 +0000 Subject: [PATCH 15/31] Update phpunit version --- php/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/composer.json b/php/composer.json index f712f0ebb9d63..756704f8fcaaf 100644 --- a/php/composer.json +++ b/php/composer.json @@ -9,7 +9,7 @@ "php": ">=7.0.0" }, "require-dev": { - "phpunit/phpunit": ">=5.0.0" + "phpunit/phpunit": ">=5.0.0 <8.5.27" }, "autoload": { "psr-4": { From 0b90ee8d3f64807c2c0d0a49dae9b16d8e839dbc Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 12 Jul 2022 13:39:56 -0700 Subject: [PATCH 16/31] address review comments --- php/ext/google/protobuf/def.c | 30 +++++++----------- php/ext/google/protobuf/names.c | 31 ++++++++----------- php/ext/google/protobuf/protobuf.c | 13 ++++---- .../protobuf/compiler/php/php_generator.cc | 2 +- 4 files changed, 32 insertions(+), 44 deletions(-) diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index ae22338702f55..018dac19ac818 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -499,29 +499,23 @@ static void Descriptor_destructor(zend_object* obj) { } static zend_class_entry *Descriptor_GetGeneratedClass(const upb_MessageDef *m) { - char *classname = - GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), false); - zend_string *str = zend_string_init(classname, strlen(classname), 0); - zend_class_entry *ce = zend_lookup_class(str); // May autoload the class. - - zend_string_release (str); - - if (!ce) { - char *classname2 = - GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), true); - zend_string *str2 = zend_string_init(classname2, strlen(classname2), 0); - ce = zend_lookup_class(str2); // May autoload the class. + for (int i = 0; i < 2; ++i) { + char *classname = + GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), (bool)i); + zend_string *str = zend_string_init(classname, strlen(classname), 0); + zend_class_entry *ce = zend_lookup_class(str); // May autoload the class. - zend_string_release (str2); - free(classname2); + zend_string_release (str); + free(classname); - if (!ce) { - zend_error(E_ERROR, "Couldn't load generated class %s", classname); + if (ce) { + return ce; } } - free(classname); - return ce; + char *classname = + GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), false); + zend_error(E_ERROR, "Couldn't load generated class %s", classname); } void Descriptor_FromMessageDef(zval *val, const upb_MessageDef *m) { diff --git a/php/ext/google/protobuf/names.c b/php/ext/google/protobuf/names.c index 87ac40de76b13..73e28186e32c9 100644 --- a/php/ext/google/protobuf/names.c +++ b/php/ext/google/protobuf/names.c @@ -103,8 +103,7 @@ bool is_reserved_name(const char* name) { } bool is_previously_unreserved_name(const char* name) { - int i; - for (i = 0; kPreviouslyUnreservedNames[i]; i++) { + for (int i = 0; kPreviouslyUnreservedNames[i]; i++) { if (strcmp(kPreviouslyUnreservedNames[i], name) == 0) { return true; } @@ -128,16 +127,18 @@ static char nolocale_toupper(char ch) { } } +static char *strdup_nolocale_lower(char *str, int length) { + char* lower = malloc(length + 1); + lower[length] = '\0'; + for(int i = 0; i < length; ++i) { + lower[i] = nolocale_tolower(str[i]); + } + return lower; +} + static bool is_reserved(const char *segment, int length, bool previous) { bool result; - char* lower = calloc(1, length + 1); - memcpy(lower, segment, length); - int i = 0; - while(lower[i]) { - lower[i] = nolocale_tolower(lower[i]); - i++; - } - lower[length] = 0; + char* lower = strdup_nolocale_lower(segment, length); result = is_reserved_name(lower); if (result && previous && is_previously_unreserved_name(lower)) { result = false; @@ -274,14 +275,8 @@ bool IsPreviouslyUnreservedClassName(const char* fullname) { } classname += 2; int length = strlen(classname); - char* lower = calloc(1, length + 1); - memcpy(lower, classname, length); - int i = 0; - while(lower[i]) { - lower[i] = nolocale_tolower(lower[i]); - i++; - } - lower[length] = 0; + char* lower =strdup_nolocale_lower(classname, length); + int j; for (j = 0; kPreviouslyUnreservedNames[j]; j++) { if (strcmp(kPreviouslyUnreservedNames[j], lower) == 0) { diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index 608ba5f12f977..a401d211c3bd7 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -242,14 +242,13 @@ bool ObjCache_Get(const void *upb_obj, zval *val) { // ----------------------------------------------------------------------------- void NameMap_AddMessage(const upb_MessageDef *m) { - char *k = GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), false); - zend_hash_str_add_ptr(&PROTOBUF_G(name_msg_cache), k, strlen(k), (void*)m); - if (IsPreviouslyUnreservedClassName(k)) { - char *k2 = GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), true); - zend_hash_str_add_ptr(&PROTOBUF_G(name_msg_cache), k2, strlen(k2), (void*)m); - free(k2); + for (int i = 0; i < 2; ++i) { + char *k = GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), (bool)i); + zend_hash_str_add_ptr(&PROTOBUF_G(name_msg_cache), k, strlen(k), (void*)m); + if (!IsPreviouslyUnreservedClassName(k)) { + return; + } } - free(k); } void NameMap_AddEnum(const upb_EnumDef *e) { diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 135a92f6545ab..6884e750352fd 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -422,7 +422,7 @@ std::string LegacyGeneratedClassFileName(const DescriptorType* desc, template std::string LegacyReadOnlyGeneratedClassFileName(const DescriptorType* desc, - const Options& options) { + const Options& options) { std::string php_namespace = RootPhpNamespace(desc, options); if (!php_namespace.empty()) { return php_namespace + "/" + desc->name() + ".php"; From 4f28c5ab4ede268f59f337c8dce6729aa7e9a7a0 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 13 Jul 2022 11:36:13 -0700 Subject: [PATCH 17/31] fix valgrind --- php/ext/google/protobuf/names.c | 6 ++---- php/ext/google/protobuf/protobuf.c | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/php/ext/google/protobuf/names.c b/php/ext/google/protobuf/names.c index 73e28186e32c9..e359d01728d99 100644 --- a/php/ext/google/protobuf/names.c +++ b/php/ext/google/protobuf/names.c @@ -275,10 +275,8 @@ bool IsPreviouslyUnreservedClassName(const char* fullname) { } classname += 2; int length = strlen(classname); - char* lower =strdup_nolocale_lower(classname, length); - - int j; - for (j = 0; kPreviouslyUnreservedNames[j]; j++) { + char* lower = strdup_nolocale_lower(classname, length); + for (int j = 0; kPreviouslyUnreservedNames[j]; j++) { if (strcmp(kPreviouslyUnreservedNames[j], lower) == 0) { free(lower); return true; diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index a401d211c3bd7..a5aba23f476bb 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -246,8 +246,10 @@ void NameMap_AddMessage(const upb_MessageDef *m) { char *k = GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), (bool)i); zend_hash_str_add_ptr(&PROTOBUF_G(name_msg_cache), k, strlen(k), (void*)m); if (!IsPreviouslyUnreservedClassName(k)) { + free(k); return; } + free(k); } } From d807712f1a27767e05b89e256cbebecb684af70a Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Fri, 15 Jul 2022 12:09:24 -0700 Subject: [PATCH 18/31] address review comments --- php/src/Google/Protobuf/Internal/Descriptor.php | 6 +++--- php/src/Google/Protobuf/Internal/DescriptorPool.php | 2 +- php/src/Google/Protobuf/Internal/GPBUtil.php | 4 ++-- src/google/protobuf/compiler/php/php_generator.cc | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/php/src/Google/Protobuf/Internal/Descriptor.php b/php/src/Google/Protobuf/Internal/Descriptor.php index b7d59cbf9b4b2..51a34d6bc9f32 100644 --- a/php/src/Google/Protobuf/Internal/Descriptor.php +++ b/php/src/Google/Protobuf/Internal/Descriptor.php @@ -163,12 +163,12 @@ public function getLegacyClass() return $this->legacy_klass; } - public function setPreviouslyReservedClass($klass) + public function setPreviouslyUnreservedClass($klass) { $this->previous_klass = $klass; } - public function getPreviouslyReservedClass() + public function getPreviouslyUnreservedClass() { return $this->previous_klass; } @@ -204,7 +204,7 @@ public static function buildFromProto($proto, $file_proto, $containing) $desc->setFullName($fullname); $desc->setClass($classname); $desc->setLegacyClass($legacy_classname); - $desc->setPreviouslyReservedClass($previous_classname); + $desc->setPreviouslyUnreservedClass($previous_classname); $desc->setOptions($proto->getOptions()); foreach ($proto->getField() as $field_proto) { diff --git a/php/src/Google/Protobuf/Internal/DescriptorPool.php b/php/src/Google/Protobuf/Internal/DescriptorPool.php index 9709a1c80e90b..1be00e2ffdfd4 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorPool.php +++ b/php/src/Google/Protobuf/Internal/DescriptorPool.php @@ -96,7 +96,7 @@ public function addDescriptor($descriptor) $descriptor->getClass(); $this->class_to_desc[$descriptor->getClass()] = $descriptor; $this->class_to_desc[$descriptor->getLegacyClass()] = $descriptor; - $this->class_to_desc[$descriptor->getPreviouslyReservedClass()] = $descriptor; + $this->class_to_desc[$descriptor->getPreviouslyUnreservedClass()] = $descriptor; foreach ($descriptor->getNestedType() as $nested_type) { $this->addDescriptor($nested_type); } diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php index 0e5cd2a7e6dee..ffea900837389 100644 --- a/php/src/Google/Protobuf/Internal/GPBUtil.php +++ b/php/src/Google/Protobuf/Internal/GPBUtil.php @@ -304,7 +304,7 @@ public static function getClassNamePrefix( return ""; } - public static function getPreviouslyUnreservedClassNamePrefix( + private static function getPreviouslyUnreservedClassNamePrefix( $classname, $file_proto) { @@ -344,7 +344,7 @@ public static function getClassNameWithoutPackage( return implode('\\', $parts); } - public static function getPreviouslyUnreservedClassNameWithoutPackage( + private static function getPreviouslyUnreservedClassNameWithoutPackage( $name, $file_proto) { diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 6884e750352fd..adfd54e5ac7aa 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -1330,7 +1330,8 @@ void LegacyReadOnlyGenerateClassFile(const FileDescriptor* file, "name", php_namespace); } std::string newname = FullClassName(desc, options); - printer.Print("class_exists(^new^::class);\n", + printer.Print("class_exists(^new^::class); // autoload the new class, which " + "will also create an alias to the deprecated class\n", "new", GeneratedClassNameImpl(desc)); printer.Print("@trigger_error(__NAMESPACE__ . '\\^old^ is deprecated and will be removed in " "the next major release. Use ^fullname^ instead', E_USER_DEPRECATED);\n\n", From 491745ac4cbc8eb5293ab327c5150361a795e872 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 19 Jul 2022 00:24:56 +0000 Subject: [PATCH 19/31] Pick up upb cherry-picks for 21.x release. --- protobuf_deps.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index 7b53b77707add..05d5fc25a6a65 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -114,6 +114,6 @@ def protobuf_deps(): _github_archive( name = "upb", repo = "https://github.com/protocolbuffers/upb", - commit = "04cb5af6b67c80db61f0aee76dcb6d233e51795c", - sha256 = "62d3519a7b65d6695e011f2733bfc5d7c6ab77f2bd83cdd2dca449da2e739c7f", + commit = "553fd5c2a77aefd4ef565e339efa8b828b8d078e", + sha256 = "6d7e139f2359104f960e045690cf1e326efd1ef3de51aa08362ecd27e1d25636" ) From 511c61263f4490fd2496cb5fc1449caa718b7754 Mon Sep 17 00:00:00 2001 From: "petr.dannhofer" Date: Fri, 8 Jul 2022 17:27:18 +0200 Subject: [PATCH 20/31] "Fixed" Visual Studio constinit errors both for clang-cl and msvc compilers under c+17 and c+20 standards --- src/google/protobuf/port_def.inc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 8858e1936826e..10005bf465266 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -638,14 +638,15 @@ #ifdef PROTOBUF_CONSTINIT #error PROTOBUF_CONSTINIT was previously defined #endif -#if defined(__cpp_constinit) +#if defined(__cpp_constinit) && !defined(_MSC_VER) #define PROTOBUF_CONSTINIT constinit #define PROTOBUF_CONSTEXPR constexpr // Some older Clang versions incorrectly raise an error about // constant-initializing weak default instance pointers. Versions 12.0 and // higher seem to work, except that XCode 12.5.1 shows the error even though it // uses Clang 12.0.5. -#elif __has_cpp_attribute(clang::require_constant_initialization) && \ +// Clang-cl on Windows raises error also. +#elif !defined(_MSC_VER) && __has_cpp_attribute(clang::require_constant_initialization) && \ ((defined(__APPLE__) && __clang_major__ >= 13) || \ (!defined(__APPLE__) && __clang_major__ >= 12)) #define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]] @@ -653,6 +654,10 @@ #elif PROTOBUF_GNUC_MIN(12, 2) #define PROTOBUF_CONSTINIT __constinit #define PROTOBUF_CONSTEXPR constexpr +// MSVC 17 currently seems to raise an error about constant-initialized pointers. +#elif defined(_MSC_VER) && _MSC_VER >= 1930 +#define PROTOBUF_CONSTINIT +#define PROTOBUF_CONSTEXPR constexpr #else #define PROTOBUF_CONSTINIT #define PROTOBUF_CONSTEXPR From 2404ea48a09a1013f8421f457d6f9a4804486cc6 Mon Sep 17 00:00:00 2001 From: Niranjan Bhaskar Date: Mon, 23 May 2022 16:04:58 -0400 Subject: [PATCH 21/31] Add header search paths to protobuf-c++ spec --- Protobuf-C++.podspec | 1 + 1 file changed, 1 insertion(+) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index e34d3430dec20..c8a516bb0563d 100644 --- a/Protobuf-C++.podspec +++ b/Protobuf-C++.podspec @@ -35,6 +35,7 @@ Pod::Spec.new do |s| # Do not let src/google/protobuf/stubs/time.h override system API 'USE_HEADERMAP' => 'NO', 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + 'HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)/src"' } end From 101b6199f33a396b5758057ca10b8f9c8d8e8855 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Tue, 19 Jul 2022 16:40:28 +0200 Subject: [PATCH 22/31] Fix #9947: make the ABI identical between debug and non-debug builds --- src/google/protobuf/message_lite.cc | 8 ++------ src/google/protobuf/metadata_lite.h | 13 ++++++++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc index 3a1b67bf66afc..da66c1965b4c4 100644 --- a/src/google/protobuf/message_lite.cc +++ b/src/google/protobuf/message_lite.cc @@ -520,18 +520,14 @@ void GenericTypeHandler::Merge(const std::string& from, *to = from; } -// Non-inline implementations of InternalMetadata routines -#if defined(NDEBUG) || defined(_MSC_VER) -// for opt and MSVC builds, the destructor is defined in the header. -#else +// Non-inline implementations of InternalMetadata destructor // This is moved out of the header because the GOOGLE_DCHECK produces a lot of code. -InternalMetadata::~InternalMetadata() { +void InternalMetadata::CheckedDestruct() { if (HasMessageOwnedArenaTag()) { GOOGLE_DCHECK(!HasUnknownFieldsTag()); delete reinterpret_cast(ptr_ - kMessageOwnedArenaTagMask); } } -#endif // Non-inline variants of std::string specializations for // various InternalMetadata routines. diff --git a/src/google/protobuf/metadata_lite.h b/src/google/protobuf/metadata_lite.h index 11faba69fca67..0c31517f08af9 100644 --- a/src/google/protobuf/metadata_lite.h +++ b/src/google/protobuf/metadata_lite.h @@ -74,15 +74,19 @@ class PROTOBUF_EXPORT InternalMetadata { GOOGLE_DCHECK(!is_message_owned || arena != nullptr); } -#if defined(NDEBUG) || defined(_MSC_VER) + // To keep the ABI identical between debug and non-debug builds, + // the destructor is always defined here even though it may delegate + // to a non-inline private method. + // (see https://github.com/protocolbuffers/protobuf/issues/9947) ~InternalMetadata() { +#if defined(NDEBUG) || defined(_MSC_VER) if (HasMessageOwnedArenaTag()) { delete reinterpret_cast(ptr_ - kMessageOwnedArenaTagMask); } - } #else - ~InternalMetadata(); + CheckedDestruct(); #endif + } template void Delete() { @@ -261,6 +265,9 @@ class PROTOBUF_EXPORT InternalMetadata { PROTOBUF_NOINLINE void DoSwap(T* other) { mutable_unknown_fields()->Swap(other); } + + // Private helper with debug checks for ~InternalMetadata() + void CheckedDestruct(); }; // String Template specializations. From 044c64937a381a94f86a1b9fc8b71291c69fb4db Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Tue, 19 Jul 2022 18:35:09 +0000 Subject: [PATCH 23/31] Upgrade upb to include another recent fix --- protobuf_deps.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index 05d5fc25a6a65..66a19013e95ca 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -114,6 +114,6 @@ def protobuf_deps(): _github_archive( name = "upb", repo = "https://github.com/protocolbuffers/upb", - commit = "553fd5c2a77aefd4ef565e339efa8b828b8d078e", - sha256 = "6d7e139f2359104f960e045690cf1e326efd1ef3de51aa08362ecd27e1d25636" + commit = "dad71550bdf01fd057c9e284fb73c5ffc8098984", + sha256 = "47b0c810b5830cd7fe7388b4f540d6d25fe4e511beb3412e1f92e21079b48dec" ) From d41d498b05576d896b93ba72f1a49e2dea3059dd Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Tue, 19 Jul 2022 18:01:58 +0000 Subject: [PATCH 24/31] Update CHANGES.txt for the 21.3 release --- CHANGES.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 6da3dbd1cb2f8..05677842fbd12 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,24 @@ +2022-07-19 version 21.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby) + C++ + * Add header search paths to Protobuf-C++.podspec (#10024) + * Fixed Visual Studio constinit errors (#10232) + * Fix #9947: make the ABI compatible between debug and non-debug builds (#10271) + + UPB + * Allow empty package names (fixes behavior regression in 4.21.0) + * Fix a SEGV bug when comparing a non-materialized sub-message (#10208) + * Fix several bugs in descriptor mapping containers (eg. descriptor.services_by_name) + * for x in mapping now yields keys rather than values, to match Python conventions and the behavior of the old library. + * Lookup operations now correctly reject unhashable types as map keys. + * We implement repr() to use the same format as dict. + * Fix maps to use the ScalarMapContainer class when appropriate + + PHP + * Add "readonly" as a keyword for PHP and add previous classnames to descriptor pool (#10041) + + Python + * Make //:protobuf_python and //:well_known_types_py_pb2 public (#10118) + 2022-06-27 version 21.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby) C++ * ArenaString improvements (fix alignment issue) From f049e5f02960d3d8b7c4f49f35dca8880636b949 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Tue, 19 Jul 2022 15:23:43 -0700 Subject: [PATCH 25/31] Update version.json to: 21.3-dev (#10275) Co-authored-by: theodorerose --- version.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/version.json b/version.json index 7e2cafea0d630..ea7c09da2a745 100644 --- a/version.json +++ b/version.json @@ -1,17 +1,17 @@ { "21.x": { - "protoc_version": "21.2", + "protoc_version": "21.3-dev", "lts": false, - "date": "2022-06-23", + "date": "2022-06-27", "languages": { - "cpp": "3.21.2", - "csharp": "3.21.2", - "java": "3.21.2", - "javascript": "3.21.2", - "objectivec": "3.21.2", - "php": "3.21.2", - "python": "4.21.2", - "ruby": "3.21.2" + "cpp": "3.21.3-dev", + "csharp": "3.21.3-dev", + "java": "3.21.3-dev", + "javascript": "3.21.3-dev", + "objectivec": "3.21.3-dev", + "php": "3.21.3-dev", + "python": "4.21.3-dev", + "ruby": "3.21.3-dev" } } } \ No newline at end of file From c8b4ef27a029831c00eaa3625ca8f37af01f847d Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 20 Jul 2022 09:27:31 -0700 Subject: [PATCH 26/31] [Bazel] Add back a filegroup for :well_known_protos (#10279) --- BUILD.bazel | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/BUILD.bazel b/BUILD.bazel index 02b3855e7ff88..0f6e41e3abdc8 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -156,6 +156,21 @@ cc_library( visibility = ["//visibility:public"], ) +# DEPRECATED: Prefer :well_known_type_protos for the Well-Known Types +# (https://developers.google.com/protocol-buffers/docs/reference/google.protobuf) +# or :descriptor_proto(_srcs) for descriptor.proto (source), or +# :compiler_plugin_proto for compiler/plugin.proto. +filegroup( + name = "well_known_protos", + srcs = [ + "src/google/protobuf/compiler/plugin.proto", + "src/google/protobuf/descriptor.proto", + ":well_known_type_protos", + ], + deprecation = "Prefer :well_known_type_protos instead.", + visibility = ["//visibility:public"], +) + filegroup( name = "well_known_type_protos", srcs = [ From 00253761b2d5074cb56719c6e5b5fabcab010ad6 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Wed, 20 Jul 2022 10:52:55 -0700 Subject: [PATCH 27/31] Upgrade upb and update CHANGES.txt (#10286) This commit upgrades upb to the latest commit on its 21.x branch to pull in this fix: https://github.com/protocolbuffers/upb/pull/717 I also updated CHANGES.txt to reflect that fix and one other Bazel change. --- CHANGES.txt | 4 ++++ protobuf_deps.bzl | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 05677842fbd12..9fc608eded2ff 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -12,6 +12,7 @@ * Lookup operations now correctly reject unhashable types as map keys. * We implement repr() to use the same format as dict. * Fix maps to use the ScalarMapContainer class when appropriate + * Fix bug when parsing an unknown value in a proto2 enum extension (protocolbuffers/upb#717) PHP * Add "readonly" as a keyword for PHP and add previous classnames to descriptor pool (#10041) @@ -19,6 +20,9 @@ Python * Make //:protobuf_python and //:well_known_types_py_pb2 public (#10118) + Bazel + * Add back a filegroup for :well_known_protos (#10061) + 2022-06-27 version 21.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby) C++ * ArenaString improvements (fix alignment issue) diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index 66a19013e95ca..bb4a294af3a2d 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -114,6 +114,6 @@ def protobuf_deps(): _github_archive( name = "upb", repo = "https://github.com/protocolbuffers/upb", - commit = "dad71550bdf01fd057c9e284fb73c5ffc8098984", - sha256 = "47b0c810b5830cd7fe7388b4f540d6d25fe4e511beb3412e1f92e21079b48dec" + commit = "672d681f196f90c890a3b2e498e89d9a40541b9d", + sha256 = "2fcfee985893cebc4341d708eb8c2fa01d501ed97049040b7b94b2a2e6eccd25", ) From b1eb1260fce7308081822413a0cba77365e7a6ab Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Wed, 20 Jul 2022 11:33:34 -0700 Subject: [PATCH 28/31] Updating version.json and repo version numbers to: 21.3 --- Protobuf-C++.podspec | 2 +- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/README.md | 6 ++--- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/kotlin-lite/pom.xml | 2 +- java/kotlin/pom.xml | 2 +- java/lite.md | 2 +- java/lite/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- php/ext/google/protobuf/package.xml | 23 +++++++++++++++---- php/ext/google/protobuf/protobuf.h | 2 +- protobuf_version.bzl | 6 ++--- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- ruby/pom.xml | 4 ++-- 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 +- version.json | 20 ++++++++-------- 37 files changed, 69 insertions(+), 54 deletions(-) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index c8a516bb0563d..b2f29d3173f63 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.21.2' + s.version = '3.21.3' s.summary = 'Protocol Buffers v3 runtime library for C++.' s.homepage = 'https://github.com/google/protobuf' s.license = 'BSD-3-Clause' diff --git a/Protobuf.podspec b/Protobuf.podspec index 85f1dc6fa1338..140a142ef5c0e 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.21.2' + s.version = '3.21.3' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = 'BSD-3-Clause' diff --git a/configure.ac b/configure.ac index c55a6a2c2f95c..10cd8c0996dd4 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.21.2],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.21.3],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index ea0559770ea42..3c2f345431a67 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.21.2 + 3.21.3 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/main/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 5517b0030cfc3..9e45d1c1ec88b 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.21.2 + 3.21.3 7.2 Google Inc. diff --git a/java/README.md b/java/README.md index 7e71e667160f5..3465f3aa23939 100644 --- a/java/README.md +++ b/java/README.md @@ -23,7 +23,7 @@ If you are using Maven, use the following: com.google.protobuf protobuf-java - 3.21.2 + 3.21.3 ``` @@ -37,7 +37,7 @@ protobuf-java-util package: com.google.protobuf protobuf-java-util - 3.21.2 + 3.21.3 ``` @@ -45,7 +45,7 @@ protobuf-java-util package: If you are using Gradle, add the following to your `build.gradle` file's dependencies: ``` - implementation 'com.google.protobuf:protobuf-java:3.21.2' + implementation 'com.google.protobuf:protobuf-java:3.21.3' ``` Again, be sure to check that the version number matches (or is newer than) the version number of protoc that you are using. diff --git a/java/bom/pom.xml b/java/bom/pom.xml index b4c3465e11808..130c967f560d1 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.21.2 + 3.21.3 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index 845ff8856acfd..5a36e6ff0fb7c 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.2 + 3.21.3 protobuf-java diff --git a/java/kotlin-lite/pom.xml b/java/kotlin-lite/pom.xml index 3fec5ec45960e..feb51224c2347 100644 --- a/java/kotlin-lite/pom.xml +++ b/java/kotlin-lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.2 + 3.21.3 protobuf-kotlin-lite diff --git a/java/kotlin/pom.xml b/java/kotlin/pom.xml index 43debafe5062c..f8a8efc7005d4 100644 --- a/java/kotlin/pom.xml +++ b/java/kotlin/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.2 + 3.21.3 protobuf-kotlin diff --git a/java/lite.md b/java/lite.md index 1ad0019847912..7243d3aabc059 100644 --- a/java/lite.md +++ b/java/lite.md @@ -29,7 +29,7 @@ protobuf Java Lite runtime. If you are using Maven, include the following: com.google.protobuf protobuf-javalite - 3.21.2 + 3.21.3 ``` diff --git a/java/lite/pom.xml b/java/lite/pom.xml index 7c635ec33f12f..d22d62f6202f2 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.2 + 3.21.3 protobuf-javalite diff --git a/java/pom.xml b/java/pom.xml index 34475a455a66e..9f38fd0f95250 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.2 + 3.21.3 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index 53f90ce6dcd13..cb19a74e89765 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.2 + 3.21.3 protobuf-java-util diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index bf3d90eb8688b..07eda42ca5252 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,11 +10,11 @@ protobuf-opensource@google.com yes - 2022-06-23 - + 2022-07-20 + - 3.21.2 - 3.21.2 + 3.21.3 + 3.21.3 stable @@ -1358,5 +1358,20 @@ G A release. + + + 3.21.3 + 3.21.3 + + + stable + stable + + 2022-07-20 + + BSD-3-Clause + + + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index c5dac329093df..0ecfb6f726af3 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -127,7 +127,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.21.2" +#define PHP_PROTOBUF_VERSION "3.21.3" // ptr -> PHP object cache. This is a weak map that caches lazily-created // wrapper objects around upb types: diff --git a/protobuf_version.bzl b/protobuf_version.bzl index b6c35f38aec73..c5d90299eb0f7 100644 --- a/protobuf_version.bzl +++ b/protobuf_version.bzl @@ -1,3 +1,3 @@ -PROTOC_VERSION = '21.2' -PROTOBUF_JAVA_VERSION = '3.21.2' -PROTOBUF_PYTHON_VERSION = '4.21.2' +PROTOC_VERSION = '21.3' +PROTOBUF_JAVA_VERSION = '3.21.3' +PROTOBUF_PYTHON_VERSION = '4.21.3' diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index bce8121b4666e..9a8d6839981af 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.21.2 + 3.21.3 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 2c3e06cc1b92f..4d3a647aefe35 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__ = '4.21.2' +__version__ = '4.21.3' diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index e7aa377519ae2..1688735f4523b 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.21.2" + s.version = "3.21.3" 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/ruby/pom.xml b/ruby/pom.xml index f1bdbf1f1f063..f1e4bef009193 100644 --- a/ruby/pom.xml +++ b/ruby/pom.xml @@ -9,7 +9,7 @@ com.google.protobuf.jruby protobuf-jruby - 3.21.2 + 3.21.3 Protocol Buffer JRuby native extension Protocol Buffers are a way of encoding structured data in an efficient yet @@ -76,7 +76,7 @@ com.google.protobuf protobuf-java-util - 3.21.2 + 3.21.3 org.jruby diff --git a/src/Makefile.am b/src/Makefile.am index ffbc36c6ac8f1..b2e509902f658 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ else PTHREAD_DEF = endif -PROTOBUF_VERSION = 32:2:0 +PROTOBUF_VERSION = 32:3: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 2368446bba627..9c924d32f05db 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 3021002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021003 < 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 ac805601aeaa3..7270a343d9429 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 3021002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021003 < 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 fd7e835e430b0..66f9e16856087 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 3021002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021003 < 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 72c8071ba2bd3..719ed6ab7c162 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 3021002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021003 < 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 87729c4893b99..827ee986ba979 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 3021002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021003 < 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 fdc398c3d900f..60f1c2164bd26 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 3021002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021003 < 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 fd75b88acec5f..71ec8928d2ec8 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 3021002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021003 < 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 10005bf465266..3f99ec2631140 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -178,7 +178,7 @@ #ifdef PROTOBUF_VERSION #error PROTOBUF_VERSION was previously defined #endif -#define PROTOBUF_VERSION 3021002 +#define PROTOBUF_VERSION 3021003 #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 fb2e29f2eafd6..03a9d1ffaaed7 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 3021002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021003 < 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 b026be358d5d8..f7a6d34ff38fc 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 3021002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021003 < 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 9d90305126cbc..4a7611c28a63e 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 3021002 +#define GOOGLE_PROTOBUF_VERSION 3021003 // 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 3b5a469b2e22a..30aeb7621555f 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 3021002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021003 < 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 bbc1265f8cc9d..8674fdfa2a835 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 3021002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021003 < 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 72304a56d1996..78c5b665ffc89 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 3021002 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021003 < 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/version.json b/version.json index ea7c09da2a745..d8ebb32af5a34 100644 --- a/version.json +++ b/version.json @@ -1,17 +1,17 @@ { "21.x": { - "protoc_version": "21.3-dev", + "protoc_version": "21.3", "lts": false, - "date": "2022-06-27", + "date": "2022-07-20", "languages": { - "cpp": "3.21.3-dev", - "csharp": "3.21.3-dev", - "java": "3.21.3-dev", - "javascript": "3.21.3-dev", - "objectivec": "3.21.3-dev", - "php": "3.21.3-dev", - "python": "4.21.3-dev", - "ruby": "3.21.3-dev" + "cpp": "3.21.3", + "csharp": "3.21.3", + "java": "3.21.3", + "javascript": "3.21.3", + "objectivec": "3.21.3", + "php": "3.21.3", + "python": "4.21.3", + "ruby": "3.21.3" } } } \ No newline at end of file From e7835368be17c82689020b6af6d84088c3b19d4e Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Thu, 21 Jul 2022 11:32:20 -0700 Subject: [PATCH 29/31] Update the release date in package.xml (#10295) We did not finish the release yesterday, so this change updates the PHP release date to today. --- php/ext/google/protobuf/package.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index 07eda42ca5252..c6ad17beb6c6d 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,8 +10,8 @@ protobuf-opensource@google.com yes - 2022-07-20 - + 2022-07-21 + 3.21.3 3.21.3 @@ -1367,8 +1367,8 @@ G A release. stable stable - 2022-07-20 - + 2022-07-21 + BSD-3-Clause From 4e7c56cf43634886e3ed7beea8dd0041dabc23db Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Thu, 21 Jul 2022 13:35:32 -0700 Subject: [PATCH 30/31] Update developer username in package.xml (#10297) I hit an error uploading to pecl.php.net, and I suspect it is because we have changed to a new username but still have the old username in package.xml. --- php/ext/google/protobuf/package.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index c6ad17beb6c6d..7b99d916f5a8a 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -5,9 +5,9 @@ Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data. https://developers.google.com/protocol-buffers/ - Bo Yang - stanleycheung - protobuf-opensource@google.com + Protobuf Team + protobufpackages + protobuf-packages@google.com yes 2022-07-21 From ddb21b2dffd8f864b517290ad8d1411cd4e68b61 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Thu, 21 Jul 2022 15:29:56 -0700 Subject: [PATCH 31/31] Update version.json to: 21.4-dev (#10299) --- version.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/version.json b/version.json index d8ebb32af5a34..3ad11d1e00504 100644 --- a/version.json +++ b/version.json @@ -1,17 +1,17 @@ { "21.x": { - "protoc_version": "21.3", + "protoc_version": "21.4-dev", "lts": false, - "date": "2022-07-20", + "date": "2022-07-21", "languages": { - "cpp": "3.21.3", - "csharp": "3.21.3", - "java": "3.21.3", - "javascript": "3.21.3", - "objectivec": "3.21.3", - "php": "3.21.3", - "python": "4.21.3", - "ruby": "3.21.3" + "cpp": "3.21.4-dev", + "csharp": "3.21.4-dev", + "java": "3.21.4-dev", + "javascript": "3.21.4-dev", + "objectivec": "3.21.4-dev", + "php": "3.21.4-dev", + "python": "4.21.4-dev", + "ruby": "3.21.4-dev" } } } \ No newline at end of file