[wp-trac] [WordPress Trac] #50244: Add bulk operation support to the Rest API

WordPress Trac noreply at wordpress.org
Wed May 27 13:21:54 UTC 2020


#50244: Add bulk operation support to the Rest API
-----------------------------+--------------------------------
 Reporter:  andraganescu     |       Owner:  TimothyBlynJacobs
     Type:  feature request  |      Status:  assigned
 Priority:  high             |   Milestone:  5.5
Component:  REST API         |     Version:  4.4
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:  performance
-----------------------------+--------------------------------

Comment (by zieladam):

 One of the conclusions was that the REST API already uses different
 functions to validate and store the data, and so it should be fairly
 straightforward to reuse them to validate the bulk first, and persist
 everything at once if the validation passed.

 Today I have been looking into flagging any places in the current menu
 controller that's doing the validation outside of `validate_callback`. I
 found the validation and sanitization are implemented all at once in
 [[https://github.com/WordPress/gutenberg/blob/2881f84896cace4cc1828774c8e09252d9e67e39/lib
 /class-wp-rest-menu-items-controller.php#L303|prepare_item_for_database]]
 and there are no separate `validate_callback` methods for each property.

 This follows the pattern from
 [[https://github.com/WordPress/WordPress/blob/master/wp-includes/rest-
 api/endpoints/class-wp-rest-posts-
 controller.php#L2210|WP_REST_Posts_Controller]] which does the exact same
 thing. The same is true for
 [[https://github.com/WordPress/WordPress/blob/master/wp-includes/rest-
 api/endpoints/class-wp-rest-comments-
 controller.php|WP_REST_Comments_Controller]],
 [[https://github.com/WordPress/WordPress/blob/master/wp-includes/rest-
 api/endpoints/class-wp-rest-attachments-controller.php|
 WP_REST_Attachments_Controller]], and potentially a lot of open source
 classes inheriting from any of these.


 It seems like the first step here would have to be refactoring these four
 classes to make them use proper `sanitize_callback` and
 `validate_callback`. What do y'all think?

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


More information about the wp-trac mailing list