Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Conversation

@rachelbaker
Copy link
Member

Consistent support for Comment create and update arguments:

  • Expands the update comment args to match the create arguments (including special handling for date_gmt)
  • Define each update argument and set sanitization callbacks
  • Removes the prepare_item_for_update method in favor of re-using the prepare_item_for_database method
  • Allow users with moderate_comments to set comment karma
  • Return an error when comment type is being changed, since wp_update_comment does not support this arg

Some other minor changes:

  • Each create argument has set default and sanitization callbacks
  • Return an error if the user is creating a comment tries to set the author to an invalid value
  • Don't set a default value for the comment_type
  • Remove double sanitization on create and update comment args

All with test coverage!!!

This sets up #1205 for the Comments endpoints.

@rachelbaker rachelbaker added this to the 2.0 Beta 2 milestone May 18, 2015
@rachelbaker
Copy link
Member Author

Fixes #940

@WP-API/amigos #reviewmerge

Copy link
Member

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!

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Related: #1205

@rachelbaker
Copy link
Member Author

I need to refresh this so we can add handling to accept date_gmt on update, even though wp_update_comment() doesn't accept the parameter.

I will also try to combine the update/create prepare for database methods to reduce the crazy.

@rachelbaker
Copy link
Member Author

Remaining:

  • Throw error for comments that are trying to change the type.
  • Add unit test for updating comment date_gmt.

I am still hoping to get this in Beta 3

@rachelbaker
Copy link
Member Author

@WP-API/amigos #reviewmerge

Fixes #940

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@joehoyle addressed in 15df46e

@joehoyle
Copy link
Member

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

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?)

@rmccue
Copy link
Member

rmccue commented Jun 17, 2015

👍 on merge, just need to fix those couple of strings. :)

rmccue added a commit that referenced this pull request Jun 18, 2015
Expand args for updating comments
@rmccue rmccue merged commit f430099 into develop Jun 18, 2015
@rmccue rmccue deleted the fix-940 branch June 18, 2015 01:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants