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." );