Skip to content

Commit f59e023

Browse files
committed
External Libraries: Append .1 to react/react-dom versions.
In 6.7, [58775] changed the way react and react-dom are bundled in Core. This commit resulted in some changes to the built files that are distributed in WordPress even though the actual version of the libraries remained the same. The result can be a blank white screen when trying to edit a post when those two script files are heavily cached. This uses `.1` as the appendage to prevent issues with third party code expecting the version number in the form `/^[\d\.]+$/`. Updates include tests in `Tests_Dependencies_Scripts::test_vendor_script_versions_registered_manually` to include the modified version used for cache busting. Reviewed by jorbin. Merges [59536] and [59540] to 6.7 branch. Props levskipg, get_dave, smerriman, jdnd, juanwp22, seanlanglands, robertstaddon, azaozz, peterwilsoncc, desrosj. Fixes #62422. git-svn-id: https://develop.svn.wordpress.org/branches/6.7@59741 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 937206b commit f59e023

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/wp-includes/script-loader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ function wp_default_packages_vendor( $scripts ) {
106106
);
107107

108108
$vendor_scripts_versions = array(
109-
'react' => '18.3.1',
110-
'react-dom' => '18.3.1',
109+
'react' => '18.3.1.1', // Final .1 due to switch to UMD build, can be removed in the next update.
110+
'react-dom' => '18.3.1.1', // Final .1 due to switch to UMD build, can be removed in the next update.
111111
'react-jsx-runtime' => '18.3.1',
112112
'regenerator-runtime' => '0.14.1',
113113
'moment' => '2.30.1',

tests/phpunit/tests/dependencies/scripts.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3413,6 +3413,21 @@ public function test_vendor_script_versions_registered_manually( $script, $handl
34133413
$handle = $script;
34143414
}
34153415

3416+
/*
3417+
* Append '.1' to the version number for React and ReactDOM.
3418+
*
3419+
* This is due to a change in the build to use the UMD version of the
3420+
* scripts, requiring a different version number in order to break the
3421+
* caches of some CDNs.
3422+
*
3423+
* This can be removed in the next update to the packages.
3424+
*
3425+
* See https://core.trac.wordpress.org/ticket/62422
3426+
*/
3427+
if ( in_array( $handle, array( 'react', 'react-dom' ), true ) ) {
3428+
$package_json[ $script ] .= '.1';
3429+
}
3430+
34163431
$script_query = $wp_scripts->query( $handle, 'registered' );
34173432

34183433
$this->assertNotFalse( $script_query, "The script '{$handle}' should be registered." );

0 commit comments

Comments
 (0)