From 9e4b268049b69e96e78bcc1ab77d9d6a4134f8cf Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 19 Dec 2024 03:07:09 +0000 Subject: [PATCH] External Libraries: Append `.1` to `react`/`react-dom` versions. Replaces the `-umd` appendage for the `react` and `react-dom` script versions with `.1`. This it to prevent issues with third party code expecting the version number in the form `/^[\d\.]+$/`. Updates the version to tests in `Tests_Dependencies_Scripts::test_vendor_script_versions_registered_manually` to include the modified version used for cache busting. Follow up to [59536], [58775]. Props azaozz, desrosj, peterwilsoncc. Fixes #62422. git-svn-id: https://develop.svn.wordpress.org/trunk@59540 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/script-loader.php | 4 ++-- tests/phpunit/tests/dependencies/scripts.php | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 14027aa52a88f..f4e37d7164139 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -106,8 +106,8 @@ function wp_default_packages_vendor( $scripts ) { ); $vendor_scripts_versions = array( - 'react' => '18.3.1-umd', - 'react-dom' => '18.3.1-umd', + 'react' => '18.3.1.1', // Final .1 due to switch to UMD build, can be removed in the next update. + 'react-dom' => '18.3.1.1', // Final .1 due to switch to UMD build, can be removed in the next update. 'react-jsx-runtime' => '18.3.1', 'regenerator-runtime' => '0.14.1', 'moment' => '2.30.1', diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index 03dba5df69744..89bfb4ef922e6 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -3413,6 +3413,21 @@ public function test_vendor_script_versions_registered_manually( $script, $handl $handle = $script; } + /* + * Append '.1' to the version number for React and ReactDOM. + * + * This is due to a change in the build to use the UMD version of the + * scripts, requiring a different version number in order to break the + * caches of some CDNs. + * + * This can be removed in the next update to the packages. + * + * See https://core.trac.wordpress.org/ticket/62422 + */ + if ( in_array( $handle, array( 'react', 'react-dom' ), true ) ) { + $package_json[ $script ] .= '.1'; + } + $script_query = $wp_scripts->query( $handle, 'registered' ); $this->assertNotFalse( $script_query, "The script '{$handle}' should be registered." );