mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-24 19:10:16 +00:00
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]. git-svn-id: https://develop.svn.wordpress.org/trunk@56093 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -710,6 +710,10 @@ class WP_REST_Menu_Items_Controller extends WP_REST_Posts_Controller {
|
||||
* @return array Item schema data.
|
||||
*/
|
||||
public function get_item_schema() {
|
||||
if ( $this->schema ) {
|
||||
return $this->add_additional_fields_schema( $this->schema );
|
||||
}
|
||||
|
||||
$schema = array(
|
||||
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
||||
'title' => $this->post_type,
|
||||
@@ -914,7 +918,9 @@ class WP_REST_Menu_Items_Controller extends WP_REST_Posts_Controller {
|
||||
$schema['links'] = $schema_links;
|
||||
}
|
||||
|
||||
return $this->add_additional_fields_schema( $schema );
|
||||
$this->schema = $schema;
|
||||
|
||||
return $this->add_additional_fields_schema( $this->schema );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user