Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 9, 2018

Conversation

danielbachhuber
Copy link
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
Copy link
Member

@noisysocks noisysocks left a comment

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
Copy link
Member

pento commented May 9, 2018

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
Copy link

lkraav commented May 9, 2018

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

@danielbachhuber
Copy link
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