From fa9d78cc8c701b31771ed35f2c1f50c53c90f06d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 24 Aug 2020 10:35:07 +0000 Subject: [PATCH] REST API: In `WP_REST_Block_Directory_Controller::get_items()`, make sure the blocks data for a plugin is not empty before proceeding. This avoids a PHP notice if the API returns a plugin with empty data for `blocks` key. Props khag7, TwentyZeroTwo, justinahinon, TimothyBlynJacobs, dd32, SergeyBiryukov. Merges [48842] to the 5.5 branch. Fixes #51018. Built from https://develop.svn.wordpress.org/branches/5.5@48849 git-svn-id: http://core.svn.wordpress.org/branches/5.5@48611 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../endpoints/class-wp-rest-block-directory-controller.php | 5 +++++ wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php index 4dc0f17fbe..8118df6489 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php @@ -95,6 +95,11 @@ class WP_REST_Block_Directory_Controller extends WP_REST_Controller { $result = array(); foreach ( $response->plugins as $plugin ) { + // If the API returned a plugin with empty data for 'blocks', skip it. + if ( empty( $plugin['blocks'] ) ) { + continue; + } + $data = $this->prepare_item_for_response( $plugin, $request ); $result[] = $this->prepare_response_for_collection( $data ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 075380a698..14c0a48c62 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5.1-alpha-48833'; +$wp_version = '5.5.1-alpha-48849'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.