Make WordPress Core

Changeset 48849 for branches/5.5


Ignore:
Timestamp:
08/24/2020 10:33:09 AM (6 years 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.
Merges [48842] to the 5.5 branch.
Fixes #51018.

Location:
branches/5.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.5

  • branches/5.5/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php

    r48656 r48849  
    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.