From eefd34a7fad6a8eea4258688fc4dbe43bd445ca8 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Tue, 8 Feb 2022 23:28:04 +0000 Subject: [PATCH] Options: Disable transients while installing. Prevent the transient setters and getters from attempting to use the database table before they exist during the installation process. During installation transients now use the `wp_cache_*()` functions on all sites, including those without a persistent cache, to prevent database errors. The use of the caching functions stores the data in memory for the duration of the request to account for transient data that is used multiple times during installation. Props dd32, audrasjb, tnolte, antonvlasenko, noisysocks, peterwilsoncc. Fixes #54849. git-svn-id: https://develop.svn.wordpress.org/trunk@52694 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/option.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index f90e82017e..d0eb6f9c83 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -784,7 +784,7 @@ function delete_transient( $transient ) { */ do_action( "delete_transient_{$transient}", $transient ); - if ( wp_using_ext_object_cache() ) { + if ( wp_using_ext_object_cache() || wp_installing() ) { $result = wp_cache_delete( $transient, 'transient' ); } else { $option_timeout = '_transient_timeout_' . $transient; @@ -846,7 +846,7 @@ function get_transient( $transient ) { return $pre; } - if ( wp_using_ext_object_cache() ) { + if ( wp_using_ext_object_cache() || wp_installing() ) { $value = wp_cache_get( $transient, 'transient' ); } else { $transient_option = '_transient_' . $transient; @@ -930,7 +930,7 @@ function set_transient( $transient, $value, $expiration = 0 ) { */ $expiration = apply_filters( "expiration_of_transient_{$transient}", $expiration, $value, $transient ); - if ( wp_using_ext_object_cache() ) { + if ( wp_using_ext_object_cache() || wp_installing() ) { $result = wp_cache_set( $transient, $value, 'transient', $expiration ); } else { $transient_timeout = '_transient_timeout_' . $transient; @@ -1858,7 +1858,7 @@ function delete_site_transient( $transient ) { */ do_action( "delete_site_transient_{$transient}", $transient ); - if ( wp_using_ext_object_cache() ) { + if ( wp_using_ext_object_cache() || wp_installing() ) { $result = wp_cache_delete( $transient, 'site-transient' ); } else { $option_timeout = '_site_transient_timeout_' . $transient; @@ -1922,7 +1922,7 @@ function get_site_transient( $transient ) { return $pre; } - if ( wp_using_ext_object_cache() ) { + if ( wp_using_ext_object_cache() || wp_installing() ) { $value = wp_cache_get( $transient, 'site-transient' ); } else { // Core transients that do not have a timeout. Listed here so querying timeouts can be avoided. @@ -2003,7 +2003,7 @@ function set_site_transient( $transient, $value, $expiration = 0 ) { */ $expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient ); - if ( wp_using_ext_object_cache() ) { + if ( wp_using_ext_object_cache() || wp_installing() ) { $result = wp_cache_set( $transient, $value, 'site-transient', $expiration ); } else { $transient_timeout = '_site_transient_timeout_' . $transient;