Make WordPress Core

Changeset 57155


Ignore:
Timestamp:
12/04/2023 07:49:18 PM (7 months ago)
Author:
flixos90
Message:

Themes: Clean up inactive themes' theme mods from being autoloaded as part of upcoming 6.5 upgrade routine.

Alongside [57153], this reduces unnecessarily autoloaded data from inactive themes, which can contribute to slow database performance as part of excessive autoloading. This changeset specifically resolves the issue for existing sites.

Props mukesh27, joemcgill, swissspidy, westonruter, flixos90.
Fixes #59975.
See #39537.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r57061 r57155  
    844844    }
    845845
     846    if ( $wp_current_db_version < 57155 ) {
     847        upgrade_650();
     848    }
     849
    846850    maybe_disable_link_manager();
    847851
     
    23512355
    23522356/**
     2357 * Executes changes made in WordPress 6.5.0.
     2358 *
     2359 * @ignore
     2360 * @since 6.5.0
     2361 *
     2362 * @global int  $wp_current_db_version The old (current) database version.
     2363 * @global wpdb $wpdb                  WordPress database abstraction object.
     2364 */
     2365function upgrade_650() {
     2366    global $wp_current_db_version, $wpdb;
     2367
     2368    if ( $wp_current_db_version < 57155 ) {
     2369        $stylesheet = get_stylesheet();
     2370
     2371        // Set autoload=no for all themes except the current one.
     2372        $theme_mods_options = $wpdb->get_col(
     2373            $wpdb->prepare(
     2374                "SELECT option_name FROM $wpdb->options WHERE autoload = 'yes' AND option_name != %s AND option_name LIKE %s",
     2375                "theme_mods_$stylesheet",
     2376                $wpdb->esc_like( 'theme_mods_' ) . '%'
     2377            )
     2378        );
     2379
     2380        $autoload = array_fill_keys( $theme_mods_options, 'no' );
     2381        wp_set_option_autoload_values( $autoload );
     2382    }
     2383}
     2384
     2385/**
    23532386 * Executes network-level upgrade routines.
    23542387 *
  • trunk/src/wp-includes/version.php

    r56967 r57155  
    2424 * @global int $wp_db_version
    2525 */
    26 $wp_db_version = 56657;
     26$wp_db_version = 57155;
    2727
    2828/**
Note: See TracChangeset for help on using the changeset viewer.