From e2a64f0cd289d1613d6939b53a581492bf2b6ee7 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 11 Aug 2021 13:01:56 +0000 Subject: [PATCH] Themes: Make sure the theme API response is not an error before operating on it in `themes_api()`. This fixes a potential bug and avoids PHP warnings when `themes_api( 'query_themes' )` is called and a successful API response is not received. Follow-up to [42632]. Props pierlo. Fixes #53913. Built from https://develop.svn.wordpress.org/trunk@51601 git-svn-id: http://core.svn.wordpress.org/trunk@51212 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/theme.php | 19 +++++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index 772e66f139..153c319656 100644 --- a/wp-admin/includes/theme.php +++ b/wp-admin/includes/theme.php @@ -602,15 +602,18 @@ function themes_api( $action, $args = array() ) { } } - // Back-compat for info/1.2 API, upgrade the theme objects in query_themes to objects. - if ( 'query_themes' === $action ) { - foreach ( $res->themes as $i => $theme ) { - $res->themes[ $i ] = (object) $theme; + if ( ! is_wp_error( $res ) ) { + // Back-compat for info/1.2 API, upgrade the theme objects in query_themes to objects. + if ( 'query_themes' === $action ) { + foreach ( $res->themes as $i => $theme ) { + $res->themes[ $i ] = (object) $theme; + } + } + + // Back-compat for info/1.2 API, downgrade the feature_list result back to an array. + if ( 'feature_list' === $action ) { + $res = (array) $res; } - } - // Back-compat for info/1.2 API, downgrade the feature_list result back to an array. - if ( 'feature_list' === $action ) { - $res = (array) $res; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index c1c1d4f2d9..8a7ebec236 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51600'; +$wp_version = '5.9-alpha-51601'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.