Skip to content

wp-build: Keep the site data preload working with WordPress 7.1 core-data - #54396

Merged
LiamSarsfield merged 5 commits into
trunkfrom
fm/mj164-wp-build-preload-fix
Nov 2, 2026
Merged

LiamSarsfield merged 5 commits into
trunkfrom
fm/mj164-wp-build-preload-fix

Conversation

@LiamSarsfield

@LiamSarsfield LiamSarsfield commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes JETPACK-3476

Proposed changes

Preload both site-data field lists in both generated page templates. This ships with Jetpack 16.4, Boost 4.9.0 and subsequent plugin builds, without a switch.

Why are these changes being made?

@wordpress/build 0.26 preloads a different field list from WordPress 7.1's core-data. My Jetpack, Newsletter, Settings and Boost therefore make a browser request, and if it fails the page is replaced with “Something went wrong!”. Both keys preserve the newer match.

WordPress 7.0 asks for a different list and still makes the request, as it did before the 0.26 update.

One more in-process REST index dispatch per render costs about 5 ms and 1 KB of inline data (33 bytes gzipped), measured locally, more on sites with many REST routes. It replaces a full browser request on WordPress 7.1.

Related product discussion/links

None.

Does this pull request change what data or activity we track or use?

No.

Testing instructions

Checked on Docker with WordPress 7.1 and system Chrome at 1440/390 px. Offline mode and Newsletter used local fixtures. Hosted sites and real connections were not checked.

Use a WordPress 7.1 site without the Gutenberg plugin active.

  1. Block /wp-json/?_fields= requests in browser DevTools.
  2. Open My Jetpack, Newsletter, Jetpack Settings and Boost. Each should render without that live request or “Something went wrong!”.
  3. Repeat My Jetpack on an unpatched build: the blocked request should cause the error.

Screenshots

Captured on Docker with the site-data request forced to return HTTP 429.

My Jetpack Before After
1440 px My Jetpack before at 1440 px My Jetpack after at 1440 px
390 px My Jetpack before at 390 px My Jetpack after at 390 px
Patched page 1440 px 390 px
Newsletter Newsletter at 1440 px Newsletter at 390 px
Jetpack Settings Jetpack Settings at 1440 px Jetpack Settings at 390 px
Boost Boost at 1440 px Boost at 390 px

Pipeline

Updates from git push no-mistakes

@LiamSarsfield
LiamSarsfield requested a review from a team as a code owner November 2, 2026 00:28
@LiamSarsfield
LiamSarsfield marked this pull request as draft November 2, 2026 00:29
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the fm/mj164-wp-build-preload-fix branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fm/mj164-wp-build-preload-fix
bin/jetpack-downloader test jetpack-mu-wpcom-plugin fm/mj164-wp-build-preload-fix

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


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

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Nov 2, 2026
@LiamSarsfield LiamSarsfield changed the title fix: restore wp-build site-data preloading on WordPress 7.1 wp-build: Keep the site data preload working with WordPress 7.1 core-data Nov 2, 2026
@jp-launch-control

jp-launch-control Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

@LiamSarsfield
LiamSarsfield marked this pull request as ready for review November 2, 2026 09:19
// 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.

$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',

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.

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

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

$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',

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.

@xavier-lc xavier-lc left a comment

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.

The new key is correct. It matches the _fields list in WordPress 7.1.4's bundled core-data.js exactly, same fields in the same order. The original key still covers sites running the Gutenberg plugin. Hunk offsets and the lockfile hash swap check out.

Suggestion: add changelog entries. The error is visible on My Jetpack, Newsletter, Jetpack Settings and Boost. Without entries, the fix won't appear in the Jetpack 16.4 or Boost 4.9.0 changelog or readme.txt. #51078, the last change to this patch, added entries to the projects it affected. At minimum: packages/my-jetpack, packages/newsletter, plugins/jetpack and plugins/boost, e.g. My Jetpack: Fix "Something went wrong!" on WordPress 7.1 when the site data request fails.

@LiamSarsfield
LiamSarsfield requested a review from a team as a code owner November 2, 2026 11:15
@github-actions github-actions Bot added [Package] My Jetpack [Package] Newsletter [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Nov 2, 2026
@LiamSarsfield

Copy link
Copy Markdown
Contributor Author

Good call @xavier-lc, I've added changelog entries for My Jetpack, Newsletter, Jetpack and Boost.

@xavier-lc xavier-lc left a comment

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.

Thanks, the changelog entries look good. Approving.

@LiamSarsfield LiamSarsfield removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Nov 2, 2026
Comment thread pnpm-workspace.yaml
Comment on lines +91 to +93
# 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.

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.

@tbradsha tbradsha left a comment

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 not a fan of the wp-build hacks, but I don't think we have much choice at this point.

@LiamSarsfield LiamSarsfield reopened this Nov 2, 2026
@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Nov 2, 2026
@LiamSarsfield
LiamSarsfield merged commit 648720d into trunk Nov 2, 2026
133 checks passed
@LiamSarsfield
LiamSarsfield deleted the fm/mj164-wp-build-preload-fix branch November 2, 2026 16:18
@github-actions github-actions Bot removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] My Jetpack [Package] Newsletter [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants