Repository navigation
wp-build: Keep the site data preload working with WordPress 7.1 core-data #54396
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
Changes from all commits
91a0f73
3db6b70
1ef7e28
9559b63
0b1a9ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,16 @@ diff --git a/templates/page-wp-admin.php.template b/templates/page-wp-admin.php. | |
| index 96c4627..48fcf28 100644 | ||
| --- a/templates/page-wp-admin.php.template | ||
| +++ b/templates/page-wp-admin.php.template | ||
| @@ -171,7 +171,26 @@ function {{PREFIX}}_{{PAGE_SLUG_UNDERSCORE}}_wp_admin_enqueue_scripts( $hook_suf | ||
| @@ -91,6 +91,8 @@ | ||
| // same fields in the same order, or the preload is never consumed. | ||
| $preload_paths = array( | ||
| '/?_fields=description,generate_animated_image_subsizes,gmt_offset,home,image_max_bit_depth,image_sizes,image_size_threshold,image_strip_meta,name,site_icon,site_icon_url,site_logo,timezone_string,url,page_for_posts,page_on_front,show_on_front', | ||
| + // WordPress 7.1's bundled core-data requests this list, without generate_animated_image_subsizes. | ||
| + '/?_fields=description,gmt_offset,home,image_max_bit_depth,image_sizes,image_size_threshold,image_strip_meta,name,site_icon,site_icon_url,site_logo,timezone_string,url,page_for_posts,page_on_front,show_on_front', | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds one more REST index dispatch to every wp-build page, about 5 ms and 1 KB of inline data, and only 7.1 sites on the bundled core-data read it. I'm fine with 7.0, 7.2 and 7.1 with a newer Gutenberg plugin paying that for nothing, because on 7.1 it replaces a browser request that can take the whole page down. |
||
| array( '/wp/v2/settings', 'OPTIONS' ), | ||
| ); | ||
|
|
||
| @@ -171,7 +173,26 @@ function {{PREFIX}}_{{PAGE_SLUG_UNDERSCORE}}_wp_admin_enqueue_scripts( $hook_suf | ||
| ( mountId, routes, initModules ) => { | ||
| const run = async () => { | ||
| const mod = await import( "@wordpress/boot" ); | ||
|
|
@@ -30,6 +39,18 @@ index 96c4627..48fcf28 100644 | |
| }; | ||
| if ( document.readyState === "loading" ) { | ||
| document.addEventListener( "DOMContentLoaded", run ); | ||
| @@ -182 +201 @@ | ||
| @@ -182 +203 @@ | ||
| - JS; | ||
| +JS; | ||
| diff --git a/templates/page.php.template b/templates/page.php.template | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This patch is hand-edited, so the first file's |
||
| --- a/templates/page.php.template | ||
| +++ b/templates/page.php.template | ||
| @@ -92,6 +92,8 @@ | ||
| // same fields in the same order, or the preload is never consumed. | ||
| $preload_paths = array( | ||
| '/?_fields=description,generate_animated_image_subsizes,gmt_offset,home,image_max_bit_depth,image_sizes,image_size_threshold,image_strip_meta,name,site_icon,site_icon_url,site_logo,timezone_string,url,page_for_posts,page_on_front,show_on_front', | ||
| + // WordPress 7.1's bundled core-data requests this list, without generate_animated_image_subsizes. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same comment as in |
||
| + '/?_fields=description,gmt_offset,home,image_max_bit_depth,image_sizes,image_size_threshold,image_strip_meta,name,site_icon,site_icon_url,site_logo,timezone_string,url,page_for_posts,page_on_front,show_on_front', | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both lists are hard-coded and nothing checks them against core-data, so the next core-data field change goes unnoticed until the live request fails and the page shows the error. This fixes today's mismatch, and I'm leaving a guard for separate work. |
||
| array( '/wp/v2/settings', 'OPTIONS' ), | ||
| ); | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,4 +88,7 @@ patchedDependencies: | |
| # It also restores the `boot-layout-container` class on the mount element, | ||
| # which those older cores' Boot uses to size the page to the viewport; 0.22.0 | ||
| # dropped it and WordPress/gutenberg#82112 (unreleased) brings it back. | ||
| # The patch also preloads WordPress 7.1's site-data field list. Keep that preload | ||
| # until Jetpack's minimum WordPress version requests the @wordpress/build 0.26 list, | ||
| # even if upstream fixes init-module handling first. | ||
|
Comment on lines
+91
to
+93
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems such an issue should be fixed upstream as well; if there's a patch here, why not push it upstream?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tbradsha I've opened WordPress/gutenberg#86185 upstream so a failed prefetch can't take the whole page down.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wary of patches to dependencies in general, but this one in particular seems quite prone to going stale. Wouldn't it be better if at least the upstream fix proposed matched the one we have here (along with a link to the upstream PR that hopefully would be merged and fix the issue)?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm, I'd like this, but the upstream fix lives in @wordpress/boot, and Jetpack's pages can load WordPress's own boot instead of ours, so patching it here might not reach the 7.1 sites that crash. The preload is the part we know reaches them unfortunately. Though if we think this edge case is unlikely I'm happy with doing it the upstream patch way for consistency I'll link WordPress/gutenberg#86185 from the patch note, and we can drop the preload once our minimum WordPress has the new field list. OK to merge this as is before the cut?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, let's go ahead and merge. |
||
| "@wordpress/build": .pnpm-patches/@wordpress__build.patch | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: patch | ||
| Type: fixed | ||
|
|
||
| Dashboard: Fix "Something went wrong!" on WordPress 7.1 when the site data request fails. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: patch | ||
| Type: fixed | ||
|
|
||
| Dashboard: Fix "Something went wrong!" on WordPress 7.1 when the site data request fails. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: patch | ||
| Type: fixed | ||
|
|
||
| Dashboard: Fix "Something went wrong!" on WordPress 7.1 when the site data request fails. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: patch | ||
| Type: bugfix | ||
|
|
||
| My Jetpack, Newsletter, Settings: Fix "Something went wrong!" on WordPress 7.1 when the site data request fails. |
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.
WordPress 7.0 and older Gutenberg plugin versions such as 23.5.0 ask for different lists, so they still make the live request and can still show "Something went wrong!", same as before the 0.26 update. I'm leaving that for now because another key would cost every site one more dispatch.