[wp-trac] [WordPress Trac] #40029: Media endpoint can return wrong number of results

WordPress Trac noreply at wordpress.org
Fri Mar 3 22:28:23 UTC 2017


#40029: Media endpoint can return wrong number of results
----------------------------+-----------------------------
 Reporter:  wonderboymusic  |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  REST API        |    Version:  4.7
 Severity:  normal          |   Keywords:  needs-patch
  Focuses:                  |
----------------------------+-----------------------------
 `WP_REST_Posts_Controller::check_read_permission()` will filter out items
 from a collection based on readability of the item's parent.

 Attachments have a weird association with a post via the "Uploaded To"
 paradigm, but can exist outside of a parent after that parent mysteriously
 disappears - example: bug in WordPress, post gets trashed and deleted but
 image does not rescind its association, etc.

 What can happen - I request 10 items on page 1 and get back 7? The
 fulfillment of the request should be opaque to the client. I have 100s of
 images - if I ask for 10, I should get 10. The SQL probably needs to be
 more aggressive by including a clause like:

 {{{
 post_parent = 0 OR post_parent IN (.... {subquery that looks only for IDs
 that exist} ....)
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40029>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list