Make WordPress Core


Ignore:
Timestamp:
06/28/2023 03:51:23 PM (2 years ago)
Author:
kadamwhite
Message:

REST API: Cache schema in block pattern and menu item endpoints.

Performance improvement to add schema caching to pattern and menu item REST endpoints, so identical schema object are not needlessly regenerated.

Props spacedmonkey.
Fixes #58657. See [45811].

File:
1 edited

Legend:

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

    r52582 r56093  
    6868     */
    6969    public function get_item_schema() {
     70        if ( $this->schema ) {
     71            return $this->add_additional_fields_schema( $this->schema );
     72        }
     73
    7074        // Do not cache this schema because all properties are derived from parent controller.
    7175        $schema = parent::get_item_schema();
     
    8791        unset( $schema['properties']['content']['properties']['rendered'] );
    8892
    89         return $schema;
     93        $this->schema = $schema;
     94
     95        return $this->add_additional_fields_schema( $this->schema );
    9096    }
    9197
Note: See TracChangeset for help on using the changeset viewer.