From 3a961371dc5736ecae12293886faea34548ef750 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Mon, 4 Dec 2023 19:38:22 +0000 Subject: [PATCH] Themes: Avoid autoloading the previous theme's theme mods when switching to another theme. This reduces unnecessarily autoloaded data from inactive themes, which can contribute to slow database performance as part of excessive autoloading. Props mukesh27, rajinsharwar, igmoweb, joemcgill, swissspidy, westonruter, flixos90. Fixes #59537. See #59975. Built from https://develop.svn.wordpress.org/trunk@57153 git-svn-id: http://core.svn.wordpress.org/trunk@56664 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/theme.php | 7 +++++++ wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/wp-includes/theme.php b/wp-includes/theme.php index f063bc97a0..81c91ab5cc 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -840,6 +840,13 @@ function switch_theme( $stylesheet ) { $new_theme->delete_pattern_cache(); $old_theme->delete_pattern_cache(); + // Set autoload=no for the old theme, autoload=yes for the switched theme. + $theme_mods_options = array( + 'theme_mods_' . $stylesheet => 'yes', + 'theme_mods_' . $old_theme->get_stylesheet() => 'no', + ); + wp_set_option_autoload_values( $theme_mods_options ); + /** * Fires after the theme is switched. * diff --git a/wp-includes/version.php b/wp-includes/version.php index f33f5ff7ee..d80bbd3d10 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5-alpha-57152'; +$wp_version = '6.5-alpha-57153'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.