Skip to content

Query for all authors with an unbounded per_page=-1 request - #6627

Merged
danielbachhuber merged 1 commit into
masterfrom
4622-unbounded-user-query
May 9, 2018
Merged

danielbachhuber merged 1 commit into
masterfrom
4622-unbounded-user-query

Conversation

@danielbachhuber

Copy link
Copy Markdown
Member

Description

Queries for all potential authors with an unbounded GET /wp/v2/users?who=authors&per_page=-1 request.

Fixes #4622
See #6180 (comment)

How has this been tested?

Generate a bunch of authors programmatically with WP-CLI:

wp user generate --role=author --count=150

See them all appear in the post author dropdown:

image

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@danielbachhuber danielbachhuber added this to the 2.9 milestone May 7, 2018
@danielbachhuber
danielbachhuber requested a review from a team May 7, 2018 22:59
@danielbachhuber danielbachhuber mentioned this pull request May 7, 2018
3 tasks done

@noisysocks noisysocks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this within Gutenberg and manually by hitting the API endpoint. Everything looks good, and I like this approach more than automatically iterating through pages on the frontend. 👍

Are we able to restrict the API so that only trusted clients (e.g. Gutenberg) can use unbounded queries? I suspect not since, from what I can tell, WP API lacks any notion of an API consumer/client.

wp user generate --role=author --count=150

Didn't know about this—very cool! 🤯

@pento

pento commented May 9, 2018

Copy link
Copy Markdown
Member

Are we able to restrict the API so that only trusted clients (e.g. Gutenberg) can use unbounded queries? I suspect not since, from what I can tell, WP API lacks any notion of an API consumer/client.

Nope, but I'm fine with it being restricted to users with edit_posts, presumably the site owner trusts those users enough that the won't try to DoS the site like this.

@danielbachhuber
danielbachhuber merged commit 8e7ee59 into master May 9, 2018
@danielbachhuber
danielbachhuber deleted the 4622-unbounded-user-query branch May 9, 2018 11:30
@lkraav

lkraav commented May 9, 2018

Copy link
Copy Markdown

@danielbachhuber is select2 implementation possible here? Traditional select element is ux horror for large lists.

@danielbachhuber

Copy link
Copy Markdown
Member Author

@lkraav Not at this time, no. See conversation in #6180 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants