Make WordPress Core


Ignore:
Timestamp:
10/27/2022 04:37:55 PM (2 years ago)
Author:
davidbaumwald
Message:

Themes: Ensure custom global styles are imported properly.

This change removes caching of global styles for logged in users, allowing "wp_global_styles" custom post type to be imported completely, regardless of any previously cached data. This change now relies on the lower-level native WP_Query cache invalidation methods for the global styles post type.

Follow-up to [52275], [54186].

Props anariel-design, bernhard-reiter, andrewserong, spacedmonkey, andraganescu, peterwilsoncc, oandregal, hellofromTonya.
Reviewed by hellofromTonya.
Merges [54706] to the 6.1 branch.
Fixes #56901.

Location:
branches/6.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.1

  • branches/6.1/src/wp-includes/class-wp-theme-json-resolver.php

    r54517 r54707  
    423423            ),
    424424        );
    425 
    426         $cache_key = sprintf( 'wp_global_styles_%s', md5( serialize( $args ) ) );
    427         $post_id   = (int) get_transient( $cache_key );
    428         // Special case: '-1' is a results not found.
    429         if ( -1 === $post_id && ! $create_post ) {
    430             return $user_cpt;
    431         }
    432 
    433         if ( $post_id > 0 && in_array( get_post_status( $post_id ), (array) $post_status_filter, true ) ) {
    434             return get_post( $post_id, ARRAY_A );
    435         }
    436425
    437426        $global_style_query = new WP_Query();
     
    457446            }
    458447        }
    459         $cache_expiration = $user_cpt ? DAY_IN_SECONDS : HOUR_IN_SECONDS;
    460         set_transient( $cache_key, $user_cpt ? $user_cpt['ID'] : -1, $cache_expiration );
    461448
    462449        return $user_cpt;
Note: See TracChangeset for help on using the changeset viewer.