-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[WIP] Comment REST API route: add support multiple statuses #9870
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
base: trunk
Are you sure you want to change the base?
[WIP] Comment REST API route: add support multiple statuses #9870
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
We might not need to extend the REST API itself. See WordPress/gutenberg#71271 (comment) |
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
Good point; that said its probably worth adding as its a simple change and reflects what the underlying core comments class already supports (so it feels like a bug or oversight that it isn't supported already). While we don't need it yet, I could easily see us or a plugin wanting this. |
src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
Outdated
Show resolved
Hide resolved
$query_params['status'] = array( | ||
'default' => 'approve', | ||
'description' => __( 'Limit result set to comments assigned a specific status. Requires authorization.' ), | ||
'sanitize_callback' => 'sanitize_key', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an issue since it only does anything for strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll expand this to handle arrays based on what we do in posts. Should be straightforward to recuse existing code for each item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added handling in 5fba5f6 calling sanitize_key
for each status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually @TimothyBJacobs I'm not sure we need this -
- sanitization only called when creating or updating a comment - in this case we should still only accept a single status value, right? sanitize_key would throw an error, maybe thats what we want?
Also, while writing tests, I noticed as far as I can see we already strictly enforce status values from a list in WP_Test_REST_Comments_Controller::handle_status_param
. Shouldn't the endpoint accept custom status values like WP_Comment_Query
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle_status_param
is for the writes though, right? This is the arg list for the query parameters so they'd be a bit different.
Are custom comment status really supported by Core? wp_get_comment_status
makes it seem like the list is fixed.
We should probably have an enum
keyword with all of the supported statuses I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback @TimothyBJacobs
We don't need this immediately so I am deprioritizing it for the moment.
src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
Outdated
Show resolved
Hide resolved
…roller.php Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
See WordPress/gutenberg#71271
Trac ticket: https://core.trac.wordpress.org/ticket/63982
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.