Skip to content

Commit

Permalink
Use get_comment_type() when comparing updating comment status
Browse files Browse the repository at this point in the history
Currently we don't allow updating a comment type, however in the update
code we are checking the raw value vs get_comment_type() which means a
comment of type "comment" can not be updated, as that's actually an
empty value in the database.
  • Loading branch information
joehoyle committed Oct 3, 2016
1 parent 7dcbf48 commit 5b3b75a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/endpoints/class-wp-rest-comments-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public function update_item( $request ) {
return new WP_Error( 'rest_comment_invalid_id', __( 'Invalid comment id.' ), array( 'status' => 404 ) );
}

if ( isset( $request['type'] ) && $request['type'] !== $comment->comment_type ) {
if ( isset( $request['type'] ) && get_comment_type( $id ) !== $request['type'] ) {
return new WP_Error( 'rest_comment_invalid_type', __( 'Sorry, you cannot change the comment type.' ), array( 'status' => 404 ) );
}

Expand Down

0 comments on commit 5b3b75a

Please sign in to comment.