Opened 4 weeks ago
Last modified 8 days ago
#62066 assigned defect (bug)
Weird ability to modify comments to be empty
Reported by: | lbones | Owned by: | Lela Bones |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | minor | Version: | |
Component: | Comments | Keywords: | |
Focuses: | rest-api | Cc: |
Description (last modified by )
When I was viewing ticket #61244, I originally misinterpreted the issue. I thought that the user wanted to avoid exporting comments that have no content, but I realized that isn't actually allowed through the WordPress editor.
However, I was trying to recreate the empty comment issue, and realized that users are able to edit comments to be empty.
I did some initial digging and WP_REST_Comments_Controller has a create_item
that contains this check:
// Do not allow comments to be created with a non-default type. if ( ! empty( $request['type'] ) && 'comment' !== $request['type'] ) { return new WP_Error( 'rest_invalid_comment_type', __( 'Cannot create a comment with that type.' ), array( 'status' => 400 ) ); }
and an update_item()
function. I think that adding this or something similar to the update_item
function would resolve this issue.
Attachments (1)
Change History (4)
#1
@
4 weeks ago
- Component changed from Posts, Post Types to Comments
- Description modified (diff)
- Focuses rest-api added
- Keywords changes-requested removed
Note: See
TracTickets for help on using
tickets.
This is in PHP 8.2 and WP 6.6.2, and it shows that you can edit comments to be null.