-
Notifications
You must be signed in to change notification settings - Fork 15.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change enum string name for reserved words #9780
Conversation
Update PHP descriptor protos
cc @bshaffer |
I understand the breaking nature of this change, while hyper focused and could be considered fixing already broken generated code, might be controversial. I opened this to get the ball rolling after a bit of discussion in the issue. |
cc @haberman |
Please be more specific in the PR description about exactly what cases will break backward compatibility. As I understand it, the cases of breakage are rare. |
Done! |
Hi @haberman what can we expect on timing here? Will this be accepted for the upcoming release or afterwards? Thanks! |
We will merge this soon and it will go into the .21.0 release early next month. I think the description somewhat overstates the breakage. As I understand it we expect it to be very rare that anyone will actually experience breakage, because:
So we don't really know of any cases were we expect this to be truly breaking. |
Changes the
string
name associated with an enum that uses a reserved word to be the enum name without thePB
prefix that the constant gets. For example the enum valueCLASS
would be generated asconst PBCLASS
and thestring
name returned by thename()
helper for it will be'CLASS'
instead of'PBCLASS'
.The
value
helper will accept either'CLASS'
or'PBCLASS'
because it will attempt to prefix the string with'PB'
before looking it up again. This "extra check" logic will only be generated for those enums that use a reserved word as a value.This is a breaking change to generated PHP code that depended on the value returned by
name()
being prefixed withPB
. This is a rare use case. Furthermore, thename()
function exists for two primary reasons:For the 1st case, the
"PB"
prefix would throw an error in the REST API, and for the 2nd case, there is no reliant code on the prefix behavior. Worth noting,serializeToJsonString
does not use thename()
function to serialize the enum into the JSON blob.Thank you @bshaffer for the concise words describing the scenarios in question.
Fixes #9763