Skip to content

Commit fcf6a84

Browse files
committed
Theme_JSON_Resolver: check for WP_Post in query.
Props oandregal, mcsf, westonruter, mukesh27. Fixes #64434. git-svn-id: https://develop.svn.wordpress.org/trunk@61400 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 9074e4e commit fcf6a84

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/wp-includes/class-wp-theme-json-resolver.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ public static function get_user_data_from_wp_global_styles( $theme, $create_post
515515

516516
$global_style_query = new WP_Query();
517517
$recent_posts = $global_style_query->query( $args );
518-
if ( count( $recent_posts ) === 1 ) {
518+
if ( count( $recent_posts ) === 1 && $recent_posts[0] instanceof WP_Post ) {
519519
$user_cpt = get_object_vars( $recent_posts[0] );
520520
} elseif ( $create_post ) {
521521
$cpt_post_id = wp_insert_post(
@@ -532,7 +532,10 @@ public static function get_user_data_from_wp_global_styles( $theme, $create_post
532532
true
533533
);
534534
if ( ! is_wp_error( $cpt_post_id ) ) {
535-
$user_cpt = get_object_vars( get_post( $cpt_post_id ) );
535+
$post = get_post( $cpt_post_id );
536+
if ( $post instanceof WP_Post ) {
537+
$user_cpt = get_object_vars( $post );
538+
}
536539
}
537540
}
538541

0 commit comments

Comments
 (0)