-
Notifications
You must be signed in to change notification settings - Fork 798
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
General: remove backwards compatibility code now that Jetpack requires WP 5.9 #24086
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
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 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
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.
I started my own PR to do the same thing. 😀 Since you got yours first, I'll just list the extra stuff I found:
- The code trying to load core's speed trap listener needs removal.
jetpack/docs/examples/bootstrap.php
Lines 66 to 69 in cde8ba3
// Using the Speed Trap Listener provided by WordPress Core testing suite to expose // slowest running tests. See the configuration in phpunit.xml.dist. require $_tests_dir . '/includes/listener-loader.php'; - Docs in monorepo.md need updating too.
Lines 237 to 238 in cde8ba3
<!-- @todo: Update this once we drop support for WP 5.8. --> Note that the state of WordPress's own PHPUnit integration is currently in flux. For WordPress 5.8 and earlier you need to both use `yoast/phpunit-polyfills` to supply polyfills and need to run with PHPUnit < 8.0 (even on PHP 8, where monkey-patching is required), while for 5.9 you can use `yoast/phpunit-polyfills` normally. Your best bet for the moment is to copy what Jetpack is doing; once the situation has stabilized, we'll update this documentation and [the example bootstrap.php](./examples/bootstrap.php). - Since Gutenberg >8.0 was included in WP 5.6, we can probably take care of this:
// TODO: Remove `replace` once minimum Gutenberg version is 8.0 (to fully support `disableLineBreaks`) - This happened back in Update wordpress monorepo #19328 and WP 5.8, we can update that and remove the referenced file too.
// TODO: replace with `import { useMergeRefs } from '@wordpress/compose';` when package is upgraded to ^3.24.4 - Gutenberg >= 7.2 seems to have happened in WP 5.5.
.components-icon-button, // Gutenberg < 7.2.0. @TODO: Remove once we drop support - PHP 5.2 was dropped in WP 5.2, so all this can be reduced to basically line 223 with a variable rename.
jetpack/projects/plugins/jetpack/modules/shortcodes/slideshow.php
Lines 221 to 251 in cde8ba3
if ( defined( 'JSON_HEX_AMP' ) ) { // This is nice to have, but not strictly necessary since we use _wp_specialchars() below. $gallery = wp_json_encode( $attr['gallery'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); // phpcs:ignore PHPCompatibility } else { $gallery = wp_json_encode( $attr['gallery'] ); } $output .= '<p class="jetpack-slideshow-noscript robots-nocontent">' . esc_html__( 'This slideshow requires JavaScript.', 'jetpack' ) . '</p>'; /* * The input to json_encode() above can contain '"'. * * For calls to json_encode() lacking the JSON_HEX_AMP option, * that '"' is left unaltered. Running '"' through esc_attr() * also leaves it unaltered since esc_attr() does not double-encode. * * This means we end up with an attribute like * `data-gallery="{"foo":"""}"`, * which is interpreted by the browser as `{"foo":"""}`, * which cannot be JSON decoded. * * The preferred workaround is to include the JSON_HEX_AMP (and friends) * options, but these are not available until 5.3.0. * Alternatively, we can use _wp_specialchars( , , , true ) instead of * esc_attr(), which will double-encode. * * Since we can't rely on JSON_HEX_AMP, we do both. * * @todo Update when minimum is PHP 5.3+ */ $gallery_attributes = _wp_specialchars( wp_check_invalid_utf8( $gallery ), ENT_QUOTES, false, true );
If you want I can push these changes to your branch.
Adding Cherry-Pick label for 10.9.1. Do not merge into the 10.9 branch until after 10.9.0 is stable. |
Co-authored-by: Brad Jorsch <[email protected]>
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.
@@ -222,8 +222,13 @@ public function slideshow_js( $attr ) { | |||
* Checking for JSON_HEX_AMP and friends here allows us to get rid of | |||
* '"', that can sometimes be included in the JSON input in some languages like French. | |||
*/ | |||
$gallery_attributes = wp_check_invalid_utf8( | |||
wp_json_encode( $attr['gallery'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ) | |||
$gallery_attributes = _wp_specialchars( |
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.
I suspect esc_attr()
might have been enough now. But this works too.
Great news! One last step: head over to your WordPress.com diff, D79521-code, and deploy it. Thank you! |
r244865-wpcom |
…Jetpack requires WP 5.9 (#24086) * General: remove backwards compatibility code for user queries See #22559 * Update PHPUnit setup to remove WP < 5.9 oddities See #21175, #21157 Primary issue: #24082 * Update docs/examples/bootstrap.php Co-authored-by: Brad Jorsch <[email protected]> * Remove speed trap listener loder * Update doc to remove mention of temporary PHPUnit situation * Remove temporary line break workaround See #15595 * Remove custom function in favor of the one that ships with core * Remove old workaround for the Jetpack sidebar plugin icon See #14327 * Remove PHP 5.2 workaround See 99fffd8 * Add back necessary _wp_specialchars wrapping Co-authored-by: Brad Jorsch <[email protected]> Co-authored-by: Brandon Kraft <[email protected]>
Cherry-picked to |
Changes proposed in this Pull Request:
Note: we will not be able to merge this until #24083 is merged.
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions: