[wp-trac] [WordPress Trac] #45269: REST API: `rest_insert_attachment` and `rest_after_insert_attachment` actions fire twice on update.

WordPress Trac noreply at wordpress.org
Sat Nov 3 14:09:46 UTC 2018


#45269: REST API: `rest_insert_attachment` and `rest_after_insert_attachment`
actions fire twice on update.
--------------------------------------+-----------------------
 Reporter:  peterwilsoncc             |       Owner:  (none)
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  5.0
Component:  REST API                  |     Version:  5.0
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  rest-api
--------------------------------------+-----------------------

Comment (by danielbachhuber):

 In [attachment:"45269.2.diff"]:

 * Adds a second `test_rest_insert_attachment_hooks_fire_once_on_create`
 test.
 * Avoids changing the execution order of `$response =
 $this->prepare_item_for_response( $post, $request );` by duplicating the
 call inside `if ( 'attachment' === $this->post_type ) {`.
 * Includes a comment mentioning where the `rest_after_insert_` action is
 fired.

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


More information about the wp-trac mailing list