Make WordPress Core

Opened 8 weeks ago

Last modified 9 days ago

#60895 assigned enhancement

Add batch support to users REST API WP_REST_Users_Controller

Reported by: alexminza's profile alexminza Owned by: timothyblynjacobs's profile TimothyBlynJacobs
Milestone: 6.6 Priority: normal
Severity: normal Version: trunk
Component: REST API Keywords: has-patch
Focuses: Cc:

Description

Following the development discussions in #53063 and #50244 for some reason batch support was not added to users.

We were working on importing a large number of users as part of a migration project to WordPress / WooCommerce to discover that WP REST API does not support batching for Users in WP_REST_Users_Controller since allow_batch is not explicitly set to true in register_rest_route.

Is there a particular reason batching was not enabled for users?
Would it make sense to add this similarly to WP_REST_Posts_Controller?

https://core.trac.wordpress.org/changeset/52068/trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

Change History (6)

This ticket was mentioned in PR #6364 on WordPress/wordpress-develop by @alexminza.


8 weeks ago
#1

  • Keywords has-patch added

Following the development discussions in #53063 and #50244 for some reason batch support was not added to users.

We were working on importing a large number of users as part of a migration project to WordPress / WooCommerce to discover that WP REST API does not support batching for Users in WP_REST_Users_Controller since allow_batch is not explicitly set to true in register_rest_route.

This PR adds batch support for users in WP_REST_Users_Controller.

Trac ticket: https://core.trac.wordpress.org/ticket/60895
Reference: https://core.trac.wordpress.org/ticket/53063

#2 @alexminza
8 weeks ago

This PR https://github.com/WordPress/wordpress-develop/pull/6364 enables batch users operations like for example creating multiple users in a single batch request:

curl --location 'http://localhost:8080/wp-json/batch/v1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ##REDACTED##' \
--data-raw '{
    "requests": [
        {
            "method": "POST",
            "path": "/wp/v2/users",
            "body": {
                "username": "testuser1",
                "email": "testuser1@localhost.local",
                "password": "##REDACTED##"
            }
        },
        {
            "method": "POST",
            "path": "/wp/v2/users",
            "body": {
                "username": "testuser2",
                "email": "testuser2@localhost.local",
                "password": "##REDACTED##"
            }
        }
    ]
}'

@alexminza commented on PR #6364:


7 weeks ago
#3

@TimothyBJacobs you added the main support for batching https://core.trac.wordpress.org/ticket/53063 - what do you think about this change?

#4 @alexminza
7 weeks ago

@TimothyBlynJacobs you added the main support for batching #53063 - what do you think about this change?

https://github.com/WordPress/wordpress-develop/pull/6364

Last edited 7 weeks ago by alexminza (previous) (diff)

#5 @TimothyBlynJacobs
7 weeks ago

  • Milestone changed from Awaiting Review to 6.6
  • Owner set to TimothyBlynJacobs
  • Status changed from new to assigned

Thanks for the patch! I’ve marked this for inclusion in 6.6.

#6 @oglekler
9 days ago

@TimothyBlynJacobs can you proceed with this patch? There are fallen Unit tests, but possibly they just need to be restarted. We have 2 weeks until Beta 1.

Note: See TracTickets for help on using tickets.