[wp-trac] [WordPress Trac] #43874: REST API: Only render fields specific to request when _fields= is used
WordPress Trac
noreply at wordpress.org
Fri Apr 27 20:57:26 UTC 2018
#43874: REST API: Only render fields specific to request when _fields= is used
-----------------------------+------------------------------------
Reporter: danielbachhuber | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.9.6
Component: REST API | Version:
Severity: normal | Resolution:
Keywords: | Focuses: rest-api, performance
-----------------------------+------------------------------------
Comment (by danielbachhuber):
Replying to [comment:3 schlessera]:
> **Possible way to make the code cleaner - variant B (with yet more code
churn):**
>
> Iterate over the `$fields` and map them to methods:
Way back in the day, I had a proposal somewhere for a similar abstraction:
define the `database_attribute` as a part of the schema, and auto-load the
data from that.
For now, I think I'll stick with some minor variation of what I already
have.
Also, it's worth noting just so it's mentioned: limiting generated
response data early means less data is passed through to
`add_additional_fields_to_object()`. This is why I've persisted `id`, in
the possibility that it's being used to pull other data into the response.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43874#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list