From f4688bac585705ba3d6de73b6551c7c12894d98d Mon Sep 17 00:00:00 2001 From: Clement Boirie Date: Tue, 29 Aug 2023 18:46:15 +0200 Subject: [PATCH] Invalidate `wp_core_block_css_files` transient when files' path and includes path doesn't match --- src/wp-includes/blocks/index.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wp-includes/blocks/index.php b/src/wp-includes/blocks/index.php index 4a95b903516f2..5c5c0d092fcfa 100644 --- a/src/wp-includes/blocks/index.php +++ b/src/wp-includes/blocks/index.php @@ -47,6 +47,12 @@ function register_core_block_style_handles() { if ( ! wp_is_development_mode( 'core' ) ) { $transient_name = 'wp_core_block_css_files'; $files = get_transient( $transient_name ); + + // Invalid cache if file's path from transient doesn't match the current includes path. + if ( is_array( $files ) && ! str_starts_with( reset( $files ), $includes_path ) ) { + $files = false; + } + if ( ! $files ) { $files = glob( wp_normalize_path( __DIR__ . '/**/**.css' ) ); set_transient( $transient_name, $files );