WordPress.org

Make WordPress Core

Changeset 48842


Ignore:
Timestamp:
08/22/2020 01:52:42 AM (3 months ago)
Author:
SergeyBiryukov
Message:

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.
Fixes #51018.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php

    r48782 r48842  
    9696
    9797        foreach ( $response->plugins as $plugin ) {
     98            // If the API returned a plugin with empty data for 'blocks', skip it.
     99            if ( empty( $plugin['blocks'] ) ) {
     100                continue;
     101            }
     102
    98103            $data     = $this->prepare_item_for_response( $plugin, $request );
    99104            $result[] = $this->prepare_response_for_collection( $data );
Note: See TracChangeset for help on using the changeset viewer.