-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fatal error when user CPT for Global Styles is deleted #45240
Comments
I have added this to the 6.1 tasks as I wonder if we want to get if fixed in 6.1? |
This would be good to fix for 6.1 if a fix can be prepared asap. Otherwise, this is a good candidate for 6.1.1. |
Taking a look at it 😄 |
TBH I'm having a bit of trouble reproducing. Can someone help me out there? What I've tried:
|
Was anyone able to reproduce this issue with WP 6.1 without the Gutenberg plugin? Because I believe the issue only exists in the plugin. First, the The Conditions:
The cache isn't purged on post deletion but relies on expiration, so the above condition results in A simple example to fake this condition: add_action( 'init', function() {
$theme = wp_get_theme();
$args = array(
'numberposts' => 1,
'orderby' => 'date',
'order' => 'desc',
'post_type' => 'wp_global_styles',
'post_status' => array( 'publish' ),
'tax_query' => array(
array(
'taxonomy' => 'wp_theme',
'field' => 'name',
'terms' => $theme->get_stylesheet(),
),
),
);
$cache_key = sprintf( 'wp_global_styles_%s', md5( serialize( $args ) ) );
// Fake cache with non-existing post ID.
wp_cache_set( $cache_key, 999999, '', HOUR_IN_SECONDS );
$data = WP_Theme_JSON_Resolver_6_1::get_user_data_from_wp_global_styles( $theme );
// The $data will be null.
var_dump( $data );
} ); |
This was fixed in the plugin via #45634. |
Description
If the user CPT for Global Styles is deleted then this line throws a fatal error:
if ( array_key_exists( 'post_content', $user_cpt ) ) {
in
wordpress-6.1/class-wp-theme-json-resolver-6-1.php
.We should check that $user_cpt is an array before we check if a key exists in it.
Step-by-step reproduction instructions
Delete the user CPT for Global Styles and reload your site.
Screenshots, screen recording, code snippet
Error:
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: