-
Notifications
You must be signed in to change notification settings - Fork 651
Expand args for updating comments #1245
Conversation
…thor to an invalid value - A user must be able to `moderate_comments` to set the author to another user_id.
WordPress expects an empty comment_type to mean the type is comment.
The input arguments are sanitized in the route args callback.
|
Fixes #940 @WP-API/amigos #reviewmerge |
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.
@rachelbaker we have an inconsistency here in the endpoints - some use the Schema to define all the update_item / create_item arguments, but here we are not doing that. One reason that may be is because we want to specify the sanitize_callback for each argument, which using the Schema does not allow us to do. Welcome to my recurring issue I've been wanting to solve for a while!
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.
@joehoyle Hmm...another issue I can see with using the Schema is that on comment update you can change the 'status' (which you cannot set on create), so that field isn't completely readonly. What do you think we should do here?
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.
@rachelbaker we probably shouldn't mark it as readonly in that case 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.
@joehoyle We also cannot set a default argument in the schema. Feels like setting the endpoint arguments from the schema is too rigid at this point to fit all our routes.
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.
Related: #1205
|
I need to refresh this so we can add handling to accept I will also try to combine the update/create prepare for database methods to reduce the crazy. |
…dpoints arguments
…for_database for both create and update
|
Remaining:
I am still hoping to get this in Beta 3 |
|
@WP-API/amigos #reviewmerge Fixes #940 |
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.
I think casting shouldn't be needed as this is sanitized with absint
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.
|
+1 from me on this, though I think @rmccue was going to look over it too. |
Sanitizing and type casting are handled in the endpoint args callbacks
…anage_comments permissions - Renames `handle_status_update` method to `handle_status_param` - Display an error if a user doesn't have permission to set the 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.
Note the smart quotes here in the string, might cause problems, since it relies on editors using UTF-8/etc. Can we use normal ' or escape sequences please? :)
(Also, they have the internet on computers now?)
|
👍 on merge, just need to fix those couple of strings. :) |
Expand args for updating comments
Consistent support for Comment create and update arguments:
date_gmt)prepare_item_for_updatemethod in favor of re-using theprepare_item_for_databasemethodmoderate_commentsto set comment karmawp_update_commentdoes not support this argSome other minor changes:
All with test coverage!!!
This sets up #1205 for the Comments endpoints.