-
Notifications
You must be signed in to change notification settings - Fork 843
Plugins: Ensure proper flags are used with json_encode() #46117
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
base: trunk
Are you sure you want to change the base?
Conversation
|
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. Debug Helper 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. Vaultpress 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. 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. Starter Plugin 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. Protect 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. Inspect 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. Automattic For agencies client 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. Classic Theme helper plugin 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. |
Code Coverage SummaryCannot generate coverage summary while tests are failing. 🤐 Please fix the tests, or re-run the Code coverage job if it was something being flaky. |
|
The change that caused this is in
However, I'm not familiar enough with the expectation of blocks. I can reproduce the failure locally with I'm not sure the proper way to fix this, nor whether this is a superficial issue that just needs something on the test side changed or one that would cause bigger issues. |
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.
Classic Theme Helper plugin changes look valid to me, thanks for updating all of this code.
I'm not sure the proper way to fix this, nor whether this is a superficial issue that just needs something on the test side changed or one that would cause bigger issues.
From what I can see, even though render_block in story.php prints the data-settings attribute with possible entity differences, view.js reads data-settings via getAttribute, then JSON.parses it. With json.parse, those entities are then normalized again.
While I'm not too sure what best practice would be generally with blocks in terms of entity expectations, I don't see anything else in the block code that uses the raw, pre-parsed attribute.
In the tests however the full HTML output is compared as a raw string to the fixture, so entity form differences will fail the assertion.
It appears as though updating the test is all that is needed. It may be worth a second opinion though.
Closes MONOREP-268
See MONOREP-129 and further discussion in p1763997995289799-slack-C05Q5HSS013.
This is a best-effort application of proper flags for
json_encode()andwp_json_encode().It also includes some cleanup of PHP 5.2 compatibility (
JSON.parse(decodeURIComponent())), which was a workaround for when the flags we now use did not exist.I've tagged for review a few teams whose plugins I know I touched.
Proposed changes:
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions: