Skip to content
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

[PHP] allow encoding enums as integers for json #12707

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

brettmc
Copy link
Contributor

@brettmc brettmc commented May 8, 2023

The php extension already had an implementation for encoding enums as integers, but it was not exposed, so add params to Message::serializeToJsonString() to enable the behaviour.
Since "preserve proto fieldnames" was already an (undocumented) boolean parameter of serializeToJsonString, I've continued that pattern by adding a second boolean param. Add the corresponding functionality to the native library, and add a test to verify the behavior.

The php extension already had an implementation for encoding enums as integers, but it was not
exposed, so add params to Message::serializeToJsonString() to enable the behaviour.
Since "preserve proto fieldnames" was already an (undocumented) boolean parameter to serializeToJsonString,
I've continued that pattern by adding a second boolean param.
Add the corresponding functionality to the native library, and add a test to verify the behavior.
@brettmc brettmc requested a review from a team as a code owner May 8, 2023 07:17
@brettmc brettmc requested review from anandolee and removed request for a team May 8, 2023 07:17
@brettmc brettmc changed the title allow encoding enums as integers for json [PHP] allow encoding enums as integers for json May 8, 2023
@acozzette acozzette added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 10, 2023
upb_Status status;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b",
&preserve_proto_fieldnames) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|bb",
Copy link
Contributor Author

@brettmc brettmc May 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses two boolean parameters, since there was a single (undocumented and ineffective) boolean parameter already there in the extension. We could consider using a bitmask depending on whether it's considered safe to do so, which might make future extension easier?
eg $message->serializeToJsonString(JSON_ENCODE_FORMAT_ENUMS_AS_INTEGERS & JSON_ENCODE_PRESERVE_PROTO_FILENAMES);

@hlopko hlopko added the php label May 30, 2023
@brettmc
Copy link
Contributor Author

brettmc commented Oct 17, 2023

Can I get any update on how this is progressing? I believe that it's been moved into google's internal systems and possibly being looked at there, but from the outside there's no sign of any activity.

Copy link

We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active, please add a comment.

This PR is labeled inactive because the last activity was over 90 days ago. This PR will be closed and archived after 14 additional days without activity.

@github-actions github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Jan 16, 2024
@brettmc
Copy link
Contributor Author

brettmc commented Jan 16, 2024

Hi. This is still active, and awaiting work/feedback/something from a maintainer.

@github-actions github-actions bot removed the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Jan 17, 2024
Copy link

We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active, please add a comment.

This PR is labeled inactive because the last activity was over 90 days ago. This PR will be closed and archived after 14 additional days without activity.

@github-actions github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Apr 17, 2024
@brettmc
Copy link
Contributor Author

brettmc commented Apr 17, 2024

Still active. Please notice me.

@github-actions github-actions bot removed the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Apr 18, 2024
Copy link

We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active, please add a comment.

This PR is labeled inactive because the last activity was over 90 days ago. This PR will be closed and archived after 14 additional days without activity.

@github-actions github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Jul 17, 2024
@brettmc
Copy link
Contributor Author

brettmc commented Jul 18, 2024

Still active/required/wanted. Pretty please notice me.

@brettmc
Copy link
Contributor Author

brettmc commented Jul 18, 2024

@anandolee can I get an update on where this PR is at, since there's no visibility of what's happening behind the scenes? Thanks!

@github-actions github-actions bot removed the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🅰️ safe for tests Mark a commit as safe to run presubmits over php
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants