[wp-trac] [WordPress Trac] #47684: Embeddable 'self' links don't work on the REST API /search endpoint

WordPress Trac noreply at wordpress.org
Thu Aug 8 14:20:48 UTC 2019


#47684: Embeddable 'self' links don't work on the REST API /search endpoint
----------------------------+------------------------------
 Reporter:  chrisvanpatten  |       Owner:  (none)
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  REST API        |     Version:
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:  rest-api
----------------------------+------------------------------

Comment (by TimothyBlynJacobs):

 > We should look at how hard it would be to make self embeddable here and
 not elsewhere, though.

 The code preventing this is fun :)

 {{{#!php
 // Ignore links to self, for obvious reasons.
 if ( 'self' === $rel ) {
         continue;
 }
 }}}

 From what I can tell, nothing immediately breaks by removing that
 restriction. However, if a developer accidentally marked a `self` link as
 `embeddable` in the "self" route, then you'd duplicate the item body. (
 for instance, marking the self link in the post controller as `embeddable`
 ). However, we wouldn't get an infinite loop because we don't process
 embeds for the embedded responses themselves.

 So if a developer made the mistake of improperly marking `self` as
 `embeddable` in an inappropriate place, it wouldn't be the end of the
 world.

 We could try to account for this, but it wouldn't be perfect. For
 instance, we could conceivably check whether the `self` link is the same
 as the currently dispatching request. If the current route was
 `wp/v2/posts/1`, we'd skip the `self` link if it was `wp/v2/posts/1`.
 However, this wouldn't catch the collection route containing post #1.

 I think lifting the restriction would be ok. Currently, it causes the
 `Tests_REST_Server::test_link_embedding_self` test to fail.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47684#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list