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

Increase default menu items per REST page to 100 #21212

Closed
kadamwhite opened this issue Mar 27, 2020 · 5 comments · Fixed by #21243
Closed

Increase default menu items per REST page to 100 #21212

kadamwhite opened this issue Mar 27, 2020 · 5 comments · Fixed by #21243
Assignees
Labels
Core REST API Task Task for Core REST API efforts REST API Interaction Related to REST API

Comments

@kadamwhite
Copy link
Contributor

Per discussion in the #core-restapi channel about the menus endpoints added in #20292, we should up the default per_page value for the new collections controllers to 100 (the maximum) as there are very few situations where you wouldn't want as comprehensive list of menu items as possible. We could also look at upping the maximum per_page for this controller specifically to a value above 100, as menus are usually already retrieved in one batch and there's less risk of custom meta and other situations that can make large collections of posts or other resources so expensive.

@mtias
Copy link
Member

mtias commented Mar 27, 2020

See also #21019

@kadamwhite kadamwhite added [Block] Navigation Affects the Navigation Block REST API Interaction Related to REST API Core REST API Task Task for Core REST API efforts labels Mar 27, 2020
@spacedmonkey
Copy link
Member

As discussed in the slack conversion, it is unwise to allow a unlimited query like this. The REST API returns a header of X-WP-TotalPages. This can be used to easily do multiple fetches of the api to get all the results. See this code snippet as an example.

@mtias
Copy link
Member

mtias commented Mar 27, 2020

I don't disagree, just connecting the existing issues. :)

@kadamwhite
Copy link
Contributor Author

@spacedmonkey It's also worth noting that (I believe this is still true) when making a request from the Gutenberg code using apiFetch, passing -1 actually triggers a middleware within apiFetch which uses that header to recursively fetch using per_page=100. -1 is still invalid within the API controller code itself.

Also cross-linking #18869 which is also related, and which raised this 10-item-limit issue originally.

@spacedmonkey
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core REST API Task Task for Core REST API efforts REST API Interaction Related to REST API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants