Script loader: Prevent DB errors during Multisite install.

Prevent the script loader from attempting to create nonces during the installation process for Multisite configurations.

Prior to this fix, multiple "Table does not exist" errors were thrown during installation if `MULTISITE` was defined in the `wp-config.php` file but the salt constants were not defined. Without the salts defined in PHP, WP was attempting to use the database fallbacks prior to table creation.

Props schlessera, johnbillion, hellofromTonya, audrasjb, costdev.
Fixes #54800.



git-svn-id: https://develop.svn.wordpress.org/trunk@52602 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson 2022-01-18 23:45:40 +00:00
parent 196361bae5
commit fc6ae7b5f6

View File

@ -309,7 +309,7 @@ function wp_default_packages_inline_scripts( $scripts ) {
array(
sprintf(
'wp.apiFetch.nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );',
( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' )
wp_installing() ? '' : wp_create_nonce( 'wp_rest' )
),
'wp.apiFetch.use( wp.apiFetch.nonceMiddleware );',
'wp.apiFetch.use( wp.apiFetch.mediaUploadMiddleware );',
@ -711,7 +711,7 @@ function wp_default_scripts( $scripts ) {
'wpApiSettings',
array(
'root' => esc_url_raw( get_rest_url() ),
'nonce' => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ),
'nonce' => wp_installing() ? '' : wp_create_nonce( 'wp_rest' ),
'versionString' => 'wp/v2/',
)
);
@ -1109,7 +1109,7 @@ function wp_default_scripts( $scripts ) {
'userProfileL10n',
array(
'user_id' => $user_id,
'nonce' => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'reset-password-for-' . $user_id ),
'nonce' => wp_installing() ? '' : wp_create_nonce( 'reset-password-for-' . $user_id ),
)
);
@ -1335,7 +1335,7 @@ function wp_default_scripts( $scripts ) {
'updates',
'_wpUpdatesSettings',
array(
'ajax_nonce' => wp_create_nonce( 'updates' ),
'ajax_nonce' => wp_installing() ? '' : wp_create_nonce( 'updates' ),
)
);