[wp-trac] [WordPress Trac] #49147: Incorrect formatting of _links on OPTIONS request to embedded collections
WordPress Trac
noreply at wordpress.org
Tue Jan 7 19:27:17 UTC 2020
#49147: Incorrect formatting of _links on OPTIONS request to embedded collections
--------------------------+-----------------------------
Reporter: nsundberg | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 4.5
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
When sending an `OPTIONS` request to a non-variable route (eg.
`/wp/v2/posts`) with `?_embed=true` and `WP_DEBUG` enabled the following
warning appears (example from 5.3.2):
{{{
Warning: Invalid argument supplied for foreach() in /wp-includes/rest-api
/class-wp-rest-server.php on line 569
}}}
This is caused by the following lines which sets the link as a string
instead of an associative array with a `href` key, like the `embed_links`
method expects: [source:/trunk/src/wp-includes/rest-api/class-wp-rest-
server.php at 47044#L1216 class-wp-rest-server.php:L1216-L1218]
{{{#!php
$data['_links'] = array(
'self' => rest_url( $route ),
);
}}}
Expected:
{{{#!php
$data['_links'] = array(
'self' => array(
'href' => rest_url( $route ),
),
);
}}}
Was about to submit a patch but when looking into it I got a bit unsure if
the `_links` property even should be included in these responses. From
what I can tell no other endpoints include the `_links` property in the
response for `OPTIONS` requests, but please advise.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49147>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list