Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions .pnpm-patches/@wordpress__build.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Copy Markdown
Contributor Author

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.

+ '/?_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',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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" );
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This patch is hand-edited, so the first file's index line is stale and this file has no index line. It still applies and installs, so I've left both as they are.

--- 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the same comment as in page-wp-admin.php.template, and the comment above the array is repeated the same way. The two templates are separate files with no shared place to put it.

+ '/?_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',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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' ),
);

52 changes: 26 additions & 26 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.
The preload here is still needed until our minimum WordPress version asks for the new field list.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.
Loading