Make WordPress Core


Ignore:
Timestamp:
10/20/2023 07:06:46 PM (13 months ago)
Author:
joemcgill
Message:

Themes: Make caches for block patterns clearable.

In [56765], theme block pattern files were cached to a transient as a performance enhancement. However, transients are not easily clearable when caches are flushed on environments not using a persistent cache, which can lead to errors if the theme files are renamed, edited, or moved.

This changes the caching mechanism to use wp_cache_set() instead, and caches these values to the global group so they are still persistent on environments using an object cache, and will be cleared by a cache flush.

In addition, the helper _wp_get_block_patterns has been moved WP_Theme::get_block_patterns for consistency with other block related theme methods and cache helpers for these values, WP_Theme::get_pattern_cache and WP_Theme::set_pattern_cache, have been made private.

Relevant unit tests updated.

Props: afercia, flixos90, mukesh27, joemcgill.
Fixes #59633. See #59591, #59490.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php

    r56042 r56978  
    2727
    2828    public function tear_down() {
     29        // Reset development mode after each test.
     30        unset( $GLOBALS['_wp_tests_development_mode'] );
     31
    2932        // Reset the theme support.
    3033        if ( $this->remove_theme_support_at_teardown ) {
Note: See TracChangeset for help on using the changeset viewer.