Make WordPress Core

Changeset 57608


Ignore:
Timestamp:
02/13/2024 08:52:23 AM (2 months ago)
Author:
spacedmonkey
Message:

Themes: Add 'theme_files' cache group to block pattern cache operations.

Use 'theme_files' cache group for block pattern caches. Previously, block pattern cache data was not stored in a cache group and used the default group. This new cache group, is setup as a global cache group, meaning that sites using multisite, will have a single cache for block pattern data per theme. This change also no longer invalidate block pattern caches in multisite instances, meaning block pattern caches can be shared between sites on a network, meaning less repeated data in the object cache.

Props spacedmonkey, flixos90, joemcgill.
Fixes #60120.

Location:
trunk
Files:
6 edited

Legend:

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

    r57584 r57608  
    19751975            return false;
    19761976        }
    1977         $pattern_data = wp_cache_get( 'wp_theme_patterns_' . $this->stylesheet );
     1977        $pattern_data = wp_cache_get( 'wp_theme_patterns_' . $this->stylesheet, 'theme_files' );
    19781978        if ( is_array( $pattern_data ) && $pattern_data['version'] === $this->get( 'Version' ) ) {
    19791979            return $pattern_data['patterns'];
     
    19941994            'patterns' => $patterns,
    19951995        );
    1996         wp_cache_set( 'wp_theme_patterns_' . $this->stylesheet, $pattern_data );
     1996        wp_cache_set( 'wp_theme_patterns_' . $this->stylesheet, $pattern_data, 'theme_files' );
    19971997    }
    19981998
     
    20032003     */
    20042004    public function delete_pattern_cache() {
    2005         wp_cache_delete( 'wp_theme_patterns_' . $this->stylesheet );
     2005        wp_cache_delete( 'wp_theme_patterns_' . $this->stylesheet, 'theme_files' );
    20062006    }
    20072007
  • trunk/src/wp-includes/load.php

    r57592 r57608  
    876876                'site-queries',
    877877                'site-transient',
     878                'theme_files',
    878879                'rss',
    879880                'users',
  • trunk/src/wp-includes/ms-blogs.php

    r57596 r57608  
    566566                        'site-queries',
    567567                        'site-transient',
     568                        'theme_files',
    568569                        'rss',
    569570                        'users',
     
    659660                        'site-queries',
    660661                        'site-transient',
     662                        'theme_files',
    661663                        'rss',
    662664                        'users',
  • trunk/src/wp-includes/theme.php

    r57584 r57608  
    838838
    839839    // Clear pattern caches.
    840     $new_theme->delete_pattern_cache();
    841     $old_theme->delete_pattern_cache();
     840    if ( ! is_multisite() ) {
     841        $new_theme->delete_pattern_cache();
     842        $old_theme->delete_pattern_cache();
     843    }
    842844
    843845    // Set autoload=no for the old theme, autoload=yes for the switched theme.
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r57149 r57608  
    413413                'site-queries',
    414414                'site-transient',
     415                'theme_files',
    415416                'rss',
    416417                'users',
  • trunk/tests/phpunit/tests/theme/wpThemeGetBlockPatterns.php

    r56978 r57608  
    8787    /**
    8888     * @ticket 59490
     89     * @group ms-excluded
    8990     */
    9091    public function test_should_clear_cache_after_switching_theme() {
Note: See TracChangeset for help on using the changeset viewer.