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

WordPress Trac noreply at wordpress.org
Wed Jun 17 21:00:47 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:  has-patch has-unit-tests  |     Focuses:  performance
--------------------------------------+--------------------------------

Comment (by TimothyBlynJacobs):

 Thanks for the review @zieladam! I've pushed some changes to the PR.

 > I think it should be opt-in - as we discussed earlier, there are
 important routes that do not support pre-validation at the moment and
 sending batch requests with validation=pre will not work as expected. With
 opt-in approach, the batch processing endpoint could be merged first and
 then more and more routes would opt-in to batch processing as time passes.

 Passing an `allow_batch` keyword is now required.

 > Great idea

 Implemented as a `validate_callback` option.

 > The only thing that could go wrong there is something unexpected
 happening between the batch validation and the handler invocation, e.g.
 requesting a batch of two requests, both trying to insert a row with the
 same value that's subject to an UNIQUE constraint - I think core should
 protect developers from doing that, but offer an option to opt out of this
 protection when more performance is required. Maybe by having two pre-
 validation modes like validation=pre-and-individual and validation=pre-
 only?

 What I've done right now is made it so it only validates once. Right now,
 that isn't an issue that would get caught by validation anyway. It'd fail
 when the `wp_insert_*` call happens.

 Leaving the choice up to the caller feels weird to me. Maybe make it
 specific to the endpoint?

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


More information about the wp-trac mailing list