Theme_JSON_Resolver: check for WP_Post in query.

Props oandregal, mcsf, westonruter, mukesh27.
Fixes #64434.

Built from https://develop.svn.wordpress.org/trunk@61400


git-svn-id: http://core.svn.wordpress.org/trunk@60712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
oandregal
2025-12-22 15:57:37 +00:00
parent 1033c6c05e
commit 36be5bb9ae
2 changed files with 6 additions and 3 deletions

View File

@@ -515,7 +515,7 @@ class WP_Theme_JSON_Resolver {
$global_style_query = new WP_Query();
$recent_posts = $global_style_query->query( $args );
if ( count( $recent_posts ) === 1 ) {
if ( count( $recent_posts ) === 1 && $recent_posts[0] instanceof WP_Post ) {
$user_cpt = get_object_vars( $recent_posts[0] );
} elseif ( $create_post ) {
$cpt_post_id = wp_insert_post(
@@ -532,7 +532,10 @@ class WP_Theme_JSON_Resolver {
true
);
if ( ! is_wp_error( $cpt_post_id ) ) {
$user_cpt = get_object_vars( get_post( $cpt_post_id ) );
$post = get_post( $cpt_post_id );
if ( $post instanceof WP_Post ) {
$user_cpt = get_object_vars( $post );
}
}
}

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '7.0-alpha-61399';
$wp_version = '7.0-alpha-61400';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.