-
Notifications
You must be signed in to change notification settings - Fork 841
Add more missing json_encode flags #46204
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
Conversation
The functions `wp_send_json()`, `wp_send_json_success()`, and `wp_send_json_error()` also have a `$flags` argument that defaults to 0. Given the nature of these functions (returning-and-exiting from ajax endpoints after setting the content type header), `JSON_UNESCAPED_SLASHES` is likely correct for all of them. Also there was one `wp_json_encode` missed, one done incorrectly in an unused test, and three added since the last PR.
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Boost plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Super Cache plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Wpcomsh plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 12 files. Only the first 5 are listed here.
Full summary · PHP report · JS report Coverage check overridden by
I don't care about code coverage for this PR
|
|
@coder-karen Since you reviewed the other two, I'm hoping you'll give this one a look too. 🙂 |
| } | ||
|
|
||
| die( wp_json_encode( $out, JSON_UNESCAPED_SLASHES ) ); | ||
| wp_send_json( $out, null, JSON_UNESCAPED_SLASHES ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of this change, I wonder if we can remove the manual headers in get_attachment_comments and post_attachment_comment ? Since if I'm understanding correctly wp_send_json sets this now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I guess that would just be get_attachment_comments, since post_attachment_comment still has various instances of die( wp_json_encode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably could, although I'm inclined not to just in case someone somewhere is doing something weird in the 'jp_carousel_check_blog_user_privileges' action or something.
Possibly at some point we should do an audit specifically for die( wp_json_encode() ), but I think I'll leave that for a different PR.
coder-karen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a look through Jetpack plugin changes and did some tests, as best as I can tell those changes make sense. For connection changes though, @bindlegirl or @sergeymitr can maybe confirm.
coder-karen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a look through Jetpack plugin changes and did some tests, as best as I can tell those changes make sense. For connection changes though, @bindlegirl or @sergeymitr can maybe confirm.
Closes MONOREP-281
Proposed changes:
The functions
wp_send_json(),wp_send_json_success(), andwp_send_json_error()also have a$flagsargument that defaults to 0. Given the nature of these functions (returning-and-exiting from ajax endpoints after setting the content type header),JSON_UNESCAPED_SLASHESis likely correct for all of them.Also there was one
wp_json_encodemissed, one done incorrectly in an unused test, and three added since the last PR.Other information:
Jetpack product discussion
See MONOREP-129 and further discussion in p1763997995289799-slack-C05Q5HSS013.
Does this pull request change what data or activity we track or use?
No
Testing instructions: