From fc6ae7b5f68770c6864b8d725f0c80824fc7a27e Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Tue, 18 Jan 2022 23:45:40 +0000 Subject: [PATCH] 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 --- src/wp-includes/script-loader.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 5964c92074..173022237c 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -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' ), ) );