Make WordPress Core

Changeset 57153


Ignore:
Timestamp:
12/04/2023 07:36:27 PM (3 months ago)
Author:
flixos90
Message:

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.

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme.php

    r57139 r57153  
    840840    $new_theme->delete_pattern_cache();
    841841    $old_theme->delete_pattern_cache();
     842
     843    // Set autoload=no for the old theme, autoload=yes for the switched theme.
     844    $theme_mods_options = array(
     845        'theme_mods_' . $stylesheet                  => 'yes',
     846        'theme_mods_' . $old_theme->get_stylesheet() => 'no',
     847    );
     848    wp_set_option_autoload_values( $theme_mods_options );
    842849
    843850    /**
Note: See TracChangeset for help on using the changeset viewer.