Repository navigation
Conversation
predict_registration() shares the rule table register_scripts() applies
predicts providers per WP/Gutenberg pair and checks opt-ins against the winning private-apis allowlist
|
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! 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. |
Code Coverage SummaryCoverage changed in 1 file.
28 files are newly checked for coverage. Only the first 5 are listed here.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
evaluate another checkout's wp-build-polyfills build; print rejections in order with a summary
Could something like this fail in CI as an early alert? |
Proposed changes
The Package Provenance module shows, on the current admin screen, which runtime serves each
wp-*package: WordPress core, the Gutenberg plugin, or Jetpack's wp-build-polyfills. Reading it across the WordPress × Gutenberg matrix still means switching the site by hand, one cell at a time.This PR adds a WP-CLI command that computes the same table for versions the site is not running, and goes one step further than the panel: it cross-checks the module names the site's bundles opt in with (
__dangerousOptInToUnstableAPIsOnlyForCoreModules( …, '@wordpress/x' )) against the allowlist of thewp-private-apiscopy that would win in that cell. A name outside that allowlist is the load-timeYou tried to opt-in to unstable APIs as module "…"error, so the command predicts that failure without loading a page.How it works:
wp-includes/js/dist, script modules, and the compiled private-apis allowlist) is read from disk for the running version, and from theWordPress/WordPressmirror on GitHub for any other release ortrunk.off,active(the installed plugin), a release version (zip downloaded from GitHub Releases) or a path to a plugin zip or directory. Bothbuild/scripts+build/modulesand the olderbuild/build-modulelayouts are understood; zips are read without extracting.WP_Build_Polyfills::predict_registration(), so the CLI and the runtime share one rule table.node_modules,vendor,testsandsrcare skipped.The command exits with status 1 when any cell rejects an opt-in, so it can gate a script.
--polyfills=<dir>and--plugins=<dirs>point it at another checkout's builds, so a branch that bumps the bundled packages can be evaluated from any site that mounts it (this is how the #51303 build was checked: its Premium Analytics bundles are the ones a Gutenberg 23.9 private-apis rejects).wp-build-polyfillsgets a publicpredict_registration( $wp_version, $gutenberg_version, $wp_version_threshold )returningforce|fallbackper handle and module;register_scripts()now reads the same policy table instead of inlining it. No behavior change.Related product discussion/links
@wordpress/*update) and the manual matrix that motivated this.@wordpress/dataviewsfrom the private-apis allowlist in Gutenberg 23.9, the case this command was built to predict.Does this pull request change what data or activity we track or use?
No.
Testing instructions
wp option update jetpack_debug_helper_active_modules '["package-provenance"]' --format=json).wp jetpack-debug provenance predictwith no arguments: it evaluates the running WordPress without Gutenberg and should match what the admin-bar panel shows on a Jetpack dashboard screen.wp jetpack-debug provenance predict --wp=7.0.4,7.1 --gutenberg=off,23.8.0and check the four cells against the rules inclass-wp-build-polyfills.php: on 7.0.4 without Gutenberg,wp-private-apisandwp-rich-textarepolyfill; with 23.8.0 they aregutenberg; on 7.1 they arecore.--gutenberg=/path/to/gutenberg.zip): every bundle that inlines DataViews 17.x/18.0 is listed as a rejected@wordpress/dataviewsopt-in and the command exits 1.jp test php plugins/debug-helperandjp test php packages/wp-build-polyfills.Sample run on a docker site (WP 7.1) with the branch build, against a Gutenberg trunk build from after WordPress/gutenberg#81478: