diff --git a/projects/packages/my-jetpack/changelog/fix-my-jetpack-wp-theme-polyfill b/projects/packages/my-jetpack/changelog/fix-my-jetpack-wp-theme-polyfill new file mode 100644 index 000000000000..5b48285659af --- /dev/null +++ b/projects/packages/my-jetpack/changelog/fix-my-jetpack-wp-theme-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix the My Jetpack app failing to load on WordPress 6.9 installs without the Gutenberg plugin active, where the wp-theme script handle it depends on is otherwise unregistered. diff --git a/projects/packages/my-jetpack/composer.json b/projects/packages/my-jetpack/composer.json index 5a4f41741ba7..418930b8b098 100644 --- a/projects/packages/my-jetpack/composer.json +++ b/projects/packages/my-jetpack/composer.json @@ -20,7 +20,8 @@ "automattic/jetpack-plans": "@dev", "automattic/jetpack-status": "@dev", "automattic/jetpack-sync": "@dev", - "automattic/jetpack-protect-status": "@dev" + "automattic/jetpack-protect-status": "@dev", + "automattic/jetpack-wp-build-polyfills": "@dev" }, "require-dev": { "yoast/phpunit-polyfills": "^4.0.0", diff --git a/projects/packages/my-jetpack/src/class-initializer.php b/projects/packages/my-jetpack/src/class-initializer.php index d2a56ea71bbd..a7da05fa418f 100644 --- a/projects/packages/my-jetpack/src/class-initializer.php +++ b/projects/packages/my-jetpack/src/class-initializer.php @@ -29,6 +29,7 @@ use Automattic\Jetpack\Sync\Functions as Sync_Functions; use Automattic\Jetpack\Terms_Of_Service; use Automattic\Jetpack\Tracking; +use Automattic\Jetpack\WP_Build_Polyfills\WP_Build_Polyfills; use Jetpack; use WP_Error; @@ -247,12 +248,37 @@ public static function can_use_analytics() { return $tracking->should_enable_tracking( new Terms_Of_Service(), $status ); } + /** + * Register polyfills for the wp-notices / wp-private-apis / wp-theme handles the + * My Jetpack app bundle depends on but WP < 7.0 does not ship (or ships with an + * incomplete allowlist). + * + * @return void + */ + public static function register_wp_build_polyfills() { + if ( ! class_exists( WP_Build_Polyfills::class ) ) { + return; + } + + WP_Build_Polyfills::register( + 'my-jetpack', + array( 'wp-notices', 'wp-private-apis', 'wp-theme' ) + ); + } + /** * Enqueue admin page assets. * * @return void */ public static function enqueue_scripts() { + // Register the wp-build-polyfills shim before the extension hook below or + // the app script can enqueue against wp-theme / wp-private-apis / wp-notices. + // WP_Build_Polyfills registers synchronously on its first caller, so calling + // it after a hook consumer would leave our handles recorded but unregistered + // for this request. + self::register_wp_build_polyfills(); + /** * Fires after the My Jetpack page is initialized. * Allows for enqueuing additional scripts only on the My Jetpack page. diff --git a/projects/packages/my-jetpack/tests/php/Register_Wp_Build_Polyfills_Test.php b/projects/packages/my-jetpack/tests/php/Register_Wp_Build_Polyfills_Test.php new file mode 100644 index 000000000000..e75d9ca27d1a --- /dev/null +++ b/projects/packages/my-jetpack/tests/php/Register_Wp_Build_Polyfills_Test.php @@ -0,0 +1,58 @@ + array(), + 'hooked' => false, + 'wp_version_threshold' => '7.0', + ) as $name => $value ) { + $prop = new ReflectionProperty( WP_Build_Polyfills::class, $name ); + if ( PHP_VERSION_ID < 80100 ) { + $prop->setAccessible( true ); + } + $prop->setValue( null, $value ); + } + parent::tearDown(); + } + + /** + * Registering requests each required handle for the `my-jetpack` consumer. + */ + public function test_registers_required_polyfill_handles() { + Initializer::register_wp_build_polyfills(); + + $consumers = WP_Build_Polyfills::get_consumers(); + + foreach ( self::EXPECTED_HANDLES as $handle ) { + $this->assertArrayHasKey( $handle, $consumers, "$handle should be requested" ); + $this->assertContains( 'my-jetpack', $consumers[ $handle ], "$handle should list the my-jetpack consumer" ); + } + } +} diff --git a/projects/plugins/backup/changelog/fix-my-jetpack-wp-theme-polyfill b/projects/plugins/backup/changelog/fix-my-jetpack-wp-theme-polyfill new file mode 100644 index 000000000000..ee676e918376 --- /dev/null +++ b/projects/plugins/backup/changelog/fix-my-jetpack-wp-theme-polyfill @@ -0,0 +1,3 @@ +Significance: patch +Type: changed +Comment: Update composer.lock. diff --git a/projects/plugins/backup/composer.lock b/projects/plugins/backup/composer.lock index 96f271205871..dff81a6e3a18 100644 --- a/projects/plugins/backup/composer.lock +++ b/projects/plugins/backup/composer.lock @@ -1325,7 +1325,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "d7e68e4abc1bfdb3cf59f52a5e181e21f886db65" + "reference": "c1600e21082d85771a93662fb7dd4f610785edf1" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1344,6 +1344,7 @@ "automattic/jetpack-redirect": "@dev", "automattic/jetpack-status": "@dev", "automattic/jetpack-sync": "@dev", + "automattic/jetpack-wp-build-polyfills": "@dev", "php": ">=7.2" }, "require-dev": { diff --git a/projects/plugins/boost/changelog/fix-my-jetpack-wp-theme-polyfill b/projects/plugins/boost/changelog/fix-my-jetpack-wp-theme-polyfill new file mode 100644 index 000000000000..0b3918424ee4 --- /dev/null +++ b/projects/plugins/boost/changelog/fix-my-jetpack-wp-theme-polyfill @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix a blank Boost admin page on WordPress 6.9 installs without the Gutenberg plugin active, where the wp-theme script handle the embedded My Jetpack app depends on was otherwise unregistered. diff --git a/projects/plugins/boost/composer.lock b/projects/plugins/boost/composer.lock index 2d95eba9da69..4937c9f3de4c 100644 --- a/projects/plugins/boost/composer.lock +++ b/projects/plugins/boost/composer.lock @@ -1242,7 +1242,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "d7e68e4abc1bfdb3cf59f52a5e181e21f886db65" + "reference": "c1600e21082d85771a93662fb7dd4f610785edf1" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1261,6 +1261,7 @@ "automattic/jetpack-redirect": "@dev", "automattic/jetpack-status": "@dev", "automattic/jetpack-sync": "@dev", + "automattic/jetpack-wp-build-polyfills": "@dev", "php": ">=7.2" }, "require-dev": { @@ -2085,6 +2086,72 @@ "relative": true } }, + { + "name": "automattic/jetpack-wp-build-polyfills", + "version": "dev-trunk", + "dist": { + "type": "path", + "url": "../../packages/wp-build-polyfills", + "reference": "116ceba3c357f49d40854f3083f60faa372f5c25" + }, + "require": { + "php": ">=7.2" + }, + "require-dev": { + "automattic/jetpack-test-environment": "@dev", + "automattic/phpunit-select-config": "@dev", + "yoast/phpunit-polyfills": "^4.0.0" + }, + "type": "jetpack-library", + "extra": { + "autotagger": true, + "mirror-repo": "Automattic/jetpack-wp-build-polyfills", + "textdomain": "jetpack-wp-build-polyfills", + "changelogger": { + "link-template": "https://github.com/Automattic/jetpack-wp-build-polyfills/compare/v${old}...v${new}" + }, + "branch-alias": { + "dev-trunk": "0.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "scripts": { + "build-production": [ + "pnpm run build-production" + ], + "build-development": [ + "pnpm run build" + ], + "phpunit": [ + "phpunit-select-config phpunit.#.xml.dist --colors=always" + ], + "test-php": [ + "@composer phpunit" + ], + "test-php-coverage": [ + "php -dpcov.directory=. ./vendor/bin/phpunit-select-config phpunit.#.xml.dist --coverage-php \"$COVERAGE_DIR/php.cov\"" + ], + "test-js": [ + "pnpm run build", + "pnpm run test" + ], + "test-js-coverage": [ + "pnpm run build", + "pnpm run test-coverage" + ] + }, + "license": [ + "GPL-2.0-or-later" + ], + "description": "Polyfills for WordPress Core packages not available or incomplete in older WP versions", + "transport-options": { + "relative": true + } + }, { "name": "automattic/jetpack-wp-js-data-sync", "version": "dev-trunk", diff --git a/projects/plugins/jetpack/changelog/fix-my-jetpack-wp-theme-polyfill b/projects/plugins/jetpack/changelog/fix-my-jetpack-wp-theme-polyfill new file mode 100644 index 000000000000..e93330c1de2e --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-my-jetpack-wp-theme-polyfill @@ -0,0 +1,3 @@ +Significance: patch +Type: other +Comment: Update composer.lock. diff --git a/projects/plugins/jetpack/composer.lock b/projects/plugins/jetpack/composer.lock index da2952137eb4..807a5320bf7c 100644 --- a/projects/plugins/jetpack/composer.lock +++ b/projects/plugins/jetpack/composer.lock @@ -2303,7 +2303,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "d7e68e4abc1bfdb3cf59f52a5e181e21f886db65" + "reference": "c1600e21082d85771a93662fb7dd4f610785edf1" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -2322,6 +2322,7 @@ "automattic/jetpack-redirect": "@dev", "automattic/jetpack-status": "@dev", "automattic/jetpack-sync": "@dev", + "automattic/jetpack-wp-build-polyfills": "@dev", "php": ">=7.2" }, "require-dev": { diff --git a/projects/plugins/protect/changelog/fix-my-jetpack-wp-theme-polyfill b/projects/plugins/protect/changelog/fix-my-jetpack-wp-theme-polyfill new file mode 100644 index 000000000000..ee676e918376 --- /dev/null +++ b/projects/plugins/protect/changelog/fix-my-jetpack-wp-theme-polyfill @@ -0,0 +1,3 @@ +Significance: patch +Type: changed +Comment: Update composer.lock. diff --git a/projects/plugins/protect/composer.lock b/projects/plugins/protect/composer.lock index a41fc1c84f53..7e65e472e4b0 100644 --- a/projects/plugins/protect/composer.lock +++ b/projects/plugins/protect/composer.lock @@ -1304,7 +1304,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "d7e68e4abc1bfdb3cf59f52a5e181e21f886db65" + "reference": "c1600e21082d85771a93662fb7dd4f610785edf1" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1323,6 +1323,7 @@ "automattic/jetpack-redirect": "@dev", "automattic/jetpack-status": "@dev", "automattic/jetpack-sync": "@dev", + "automattic/jetpack-wp-build-polyfills": "@dev", "php": ">=7.2" }, "require-dev": { @@ -2101,6 +2102,72 @@ "relative": true } }, + { + "name": "automattic/jetpack-wp-build-polyfills", + "version": "dev-trunk", + "dist": { + "type": "path", + "url": "../../packages/wp-build-polyfills", + "reference": "116ceba3c357f49d40854f3083f60faa372f5c25" + }, + "require": { + "php": ">=7.2" + }, + "require-dev": { + "automattic/jetpack-test-environment": "@dev", + "automattic/phpunit-select-config": "@dev", + "yoast/phpunit-polyfills": "^4.0.0" + }, + "type": "jetpack-library", + "extra": { + "autotagger": true, + "mirror-repo": "Automattic/jetpack-wp-build-polyfills", + "textdomain": "jetpack-wp-build-polyfills", + "changelogger": { + "link-template": "https://github.com/Automattic/jetpack-wp-build-polyfills/compare/v${old}...v${new}" + }, + "branch-alias": { + "dev-trunk": "0.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "scripts": { + "build-production": [ + "pnpm run build-production" + ], + "build-development": [ + "pnpm run build" + ], + "phpunit": [ + "phpunit-select-config phpunit.#.xml.dist --colors=always" + ], + "test-php": [ + "@composer phpunit" + ], + "test-php-coverage": [ + "php -dpcov.directory=. ./vendor/bin/phpunit-select-config phpunit.#.xml.dist --coverage-php \"$COVERAGE_DIR/php.cov\"" + ], + "test-js": [ + "pnpm run build", + "pnpm run test" + ], + "test-js-coverage": [ + "pnpm run build", + "pnpm run test-coverage" + ] + }, + "license": [ + "GPL-2.0-or-later" + ], + "description": "Polyfills for WordPress Core packages not available or incomplete in older WP versions", + "transport-options": { + "relative": true + } + }, { "name": "wikimedia/aho-corasick", "version": "v1.0.1", diff --git a/projects/plugins/search/changelog/fix-my-jetpack-wp-theme-polyfill b/projects/plugins/search/changelog/fix-my-jetpack-wp-theme-polyfill new file mode 100644 index 000000000000..ee676e918376 --- /dev/null +++ b/projects/plugins/search/changelog/fix-my-jetpack-wp-theme-polyfill @@ -0,0 +1,3 @@ +Significance: patch +Type: changed +Comment: Update composer.lock. diff --git a/projects/plugins/search/composer.lock b/projects/plugins/search/composer.lock index 245c91c29e91..15febd96abb5 100644 --- a/projects/plugins/search/composer.lock +++ b/projects/plugins/search/composer.lock @@ -1182,7 +1182,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "d7e68e4abc1bfdb3cf59f52a5e181e21f886db65" + "reference": "c1600e21082d85771a93662fb7dd4f610785edf1" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1201,6 +1201,7 @@ "automattic/jetpack-redirect": "@dev", "automattic/jetpack-status": "@dev", "automattic/jetpack-sync": "@dev", + "automattic/jetpack-wp-build-polyfills": "@dev", "php": ">=7.2" }, "require-dev": { @@ -2044,6 +2045,72 @@ "transport-options": { "relative": true } + }, + { + "name": "automattic/jetpack-wp-build-polyfills", + "version": "dev-trunk", + "dist": { + "type": "path", + "url": "../../packages/wp-build-polyfills", + "reference": "116ceba3c357f49d40854f3083f60faa372f5c25" + }, + "require": { + "php": ">=7.2" + }, + "require-dev": { + "automattic/jetpack-test-environment": "@dev", + "automattic/phpunit-select-config": "@dev", + "yoast/phpunit-polyfills": "^4.0.0" + }, + "type": "jetpack-library", + "extra": { + "autotagger": true, + "mirror-repo": "Automattic/jetpack-wp-build-polyfills", + "textdomain": "jetpack-wp-build-polyfills", + "changelogger": { + "link-template": "https://github.com/Automattic/jetpack-wp-build-polyfills/compare/v${old}...v${new}" + }, + "branch-alias": { + "dev-trunk": "0.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "scripts": { + "build-production": [ + "pnpm run build-production" + ], + "build-development": [ + "pnpm run build" + ], + "phpunit": [ + "phpunit-select-config phpunit.#.xml.dist --colors=always" + ], + "test-php": [ + "@composer phpunit" + ], + "test-php-coverage": [ + "php -dpcov.directory=. ./vendor/bin/phpunit-select-config phpunit.#.xml.dist --coverage-php \"$COVERAGE_DIR/php.cov\"" + ], + "test-js": [ + "pnpm run build", + "pnpm run test" + ], + "test-js-coverage": [ + "pnpm run build", + "pnpm run test-coverage" + ] + }, + "license": [ + "GPL-2.0-or-later" + ], + "description": "Polyfills for WordPress Core packages not available or incomplete in older WP versions", + "transport-options": { + "relative": true + } } ], "packages-dev": [ diff --git a/projects/plugins/social/changelog/fix-my-jetpack-wp-theme-polyfill b/projects/plugins/social/changelog/fix-my-jetpack-wp-theme-polyfill new file mode 100644 index 000000000000..ee676e918376 --- /dev/null +++ b/projects/plugins/social/changelog/fix-my-jetpack-wp-theme-polyfill @@ -0,0 +1,3 @@ +Significance: patch +Type: changed +Comment: Update composer.lock. diff --git a/projects/plugins/social/composer.lock b/projects/plugins/social/composer.lock index c34ce7d9fa98..6d4fe580ef05 100644 --- a/projects/plugins/social/composer.lock +++ b/projects/plugins/social/composer.lock @@ -1305,7 +1305,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "d7e68e4abc1bfdb3cf59f52a5e181e21f886db65" + "reference": "c1600e21082d85771a93662fb7dd4f610785edf1" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1324,6 +1324,7 @@ "automattic/jetpack-redirect": "@dev", "automattic/jetpack-status": "@dev", "automattic/jetpack-sync": "@dev", + "automattic/jetpack-wp-build-polyfills": "@dev", "php": ">=7.2" }, "require-dev": { diff --git a/projects/plugins/starter-plugin/changelog/fix-my-jetpack-wp-theme-polyfill b/projects/plugins/starter-plugin/changelog/fix-my-jetpack-wp-theme-polyfill new file mode 100644 index 000000000000..ee676e918376 --- /dev/null +++ b/projects/plugins/starter-plugin/changelog/fix-my-jetpack-wp-theme-polyfill @@ -0,0 +1,3 @@ +Significance: patch +Type: changed +Comment: Update composer.lock. diff --git a/projects/plugins/starter-plugin/composer.lock b/projects/plugins/starter-plugin/composer.lock index 4b764a2f441a..3ee42cac44c8 100644 --- a/projects/plugins/starter-plugin/composer.lock +++ b/projects/plugins/starter-plugin/composer.lock @@ -1182,7 +1182,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "d7e68e4abc1bfdb3cf59f52a5e181e21f886db65" + "reference": "c1600e21082d85771a93662fb7dd4f610785edf1" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1201,6 +1201,7 @@ "automattic/jetpack-redirect": "@dev", "automattic/jetpack-status": "@dev", "automattic/jetpack-sync": "@dev", + "automattic/jetpack-wp-build-polyfills": "@dev", "php": ">=7.2" }, "require-dev": { @@ -1834,6 +1835,72 @@ "transport-options": { "relative": true } + }, + { + "name": "automattic/jetpack-wp-build-polyfills", + "version": "dev-trunk", + "dist": { + "type": "path", + "url": "../../packages/wp-build-polyfills", + "reference": "116ceba3c357f49d40854f3083f60faa372f5c25" + }, + "require": { + "php": ">=7.2" + }, + "require-dev": { + "automattic/jetpack-test-environment": "@dev", + "automattic/phpunit-select-config": "@dev", + "yoast/phpunit-polyfills": "^4.0.0" + }, + "type": "jetpack-library", + "extra": { + "autotagger": true, + "mirror-repo": "Automattic/jetpack-wp-build-polyfills", + "textdomain": "jetpack-wp-build-polyfills", + "changelogger": { + "link-template": "https://github.com/Automattic/jetpack-wp-build-polyfills/compare/v${old}...v${new}" + }, + "branch-alias": { + "dev-trunk": "0.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "scripts": { + "build-production": [ + "pnpm run build-production" + ], + "build-development": [ + "pnpm run build" + ], + "phpunit": [ + "phpunit-select-config phpunit.#.xml.dist --colors=always" + ], + "test-php": [ + "@composer phpunit" + ], + "test-php-coverage": [ + "php -dpcov.directory=. ./vendor/bin/phpunit-select-config phpunit.#.xml.dist --coverage-php \"$COVERAGE_DIR/php.cov\"" + ], + "test-js": [ + "pnpm run build", + "pnpm run test" + ], + "test-js-coverage": [ + "pnpm run build", + "pnpm run test-coverage" + ] + }, + "license": [ + "GPL-2.0-or-later" + ], + "description": "Polyfills for WordPress Core packages not available or incomplete in older WP versions", + "transport-options": { + "relative": true + } } ], "packages-dev": [ diff --git a/projects/plugins/videopress/changelog/fix-my-jetpack-wp-theme-polyfill b/projects/plugins/videopress/changelog/fix-my-jetpack-wp-theme-polyfill new file mode 100644 index 000000000000..ee676e918376 --- /dev/null +++ b/projects/plugins/videopress/changelog/fix-my-jetpack-wp-theme-polyfill @@ -0,0 +1,3 @@ +Significance: patch +Type: changed +Comment: Update composer.lock. diff --git a/projects/plugins/videopress/composer.lock b/projects/plugins/videopress/composer.lock index 2c2d124d7304..91a882306dc2 100644 --- a/projects/plugins/videopress/composer.lock +++ b/projects/plugins/videopress/composer.lock @@ -1182,7 +1182,7 @@ "dist": { "type": "path", "url": "../../packages/my-jetpack", - "reference": "d7e68e4abc1bfdb3cf59f52a5e181e21f886db65" + "reference": "c1600e21082d85771a93662fb7dd4f610785edf1" }, "require": { "automattic/jetpack-admin-ui": "@dev", @@ -1201,6 +1201,7 @@ "automattic/jetpack-redirect": "@dev", "automattic/jetpack-status": "@dev", "automattic/jetpack-sync": "@dev", + "automattic/jetpack-wp-build-polyfills": "@dev", "php": ">=7.2" }, "require-dev": {