Skip to content

Commit

Permalink
Use low-level cache for get_user_data_from_wp_global_styles().
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilsoncc committed Oct 24, 2022
1 parent a5463b4 commit 16aac5e
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/wp-includes/class-wp-theme-json-resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,17 +423,6 @@ public static function get_user_data_from_wp_global_styles( $theme, $create_post
),
);

$cache_key = sprintf( 'wp_global_styles_%s', md5( serialize( $args ) ) );
$post_id = (int) get_transient( $cache_key );
// Special case: '-1' is a results not found.
if ( -1 === $post_id && ! $create_post ) {
return $user_cpt;
}

if ( $post_id > 0 && in_array( get_post_status( $post_id ), (array) $post_status_filter, true ) ) {
return get_post( $post_id, ARRAY_A );
}

$global_style_query = new WP_Query();
$recent_posts = $global_style_query->query( $args );
if ( count( $recent_posts ) === 1 ) {
Expand All @@ -456,8 +445,6 @@ public static function get_user_data_from_wp_global_styles( $theme, $create_post
$user_cpt = get_post( $cpt_post_id, ARRAY_A );
}
}
$cache_expiration = $user_cpt ? DAY_IN_SECONDS : HOUR_IN_SECONDS;
set_transient( $cache_key, $user_cpt ? $user_cpt['ID'] : -1, $cache_expiration );

return $user_cpt;
}
Expand Down

0 comments on commit 16aac5e

Please sign in to comment.