Make WordPress Core


Ignore:
Timestamp:
07/22/2022 01:58:46 PM (4 years ago)
Author:
spacedmonkey
Message:

REST API: Avoid unnecessarily preparing item links.

Do not call the prepare_links methods in core REST API controllers, unless the _links or _embedded fields are requested. There is no need to prepare links if they are never returned in the response. This saves resources, as many calls to prepare_links methods perform database queries.

Props Spacedmonkey, timothyblynjacobs, rachelbaker, desrosj, dlh, hellofromTonya.
Fixes #52992.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-search-controller.php

    r53485 r53760  
    444444                                'id',
    445445                                'title',
    446                                 '_links',
    447446                        ),
    448447                        array_keys( $data[0] )
Note: See TracChangeset for help on using the changeset viewer.