[wp-trac] [WordPress Trac] #52640: The rest_prepare_attachment filter runs twice during REST request

WordPress Trac noreply at wordpress.org
Wed Feb 24 17:44:57 UTC 2021


#52640: The rest_prepare_attachment filter runs twice during REST request
--------------------------------------+-----------------------------
 Reporter:  chrisl27                  |       Owner:  (none)
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  Future Release
Component:  REST API                  |     Version:  trunk
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+-----------------------------
Changes (by TimothyBlynJacobs):

 * milestone:  Awaiting Review => Future Release


Comment:

 Thanks for the ticket @chrisl27!

 In core this is just the attachments controller, so we could do the
 hardcoded check for the `attachment` post type, but this is a tricky issue
 since it'd apply whenever a plugin tries to override
 `prepare_item_for_response`.

 I wonder if instead we should refactor the attachments controller to use
 the filter instead of overriding the method, and encourage plugins to use
 the filter.

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


More information about the wp-trac mailing list