Opened 2 years ago
Last modified 23 months ago
#62066 assigned defect (bug)
Weird ability to modify comments to be empty
| Reported by: | lbones | Owned by: | Lela Bones |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Comments | Version: | |
| Severity: | minor | Keywords: | |
| Cc: | Focuses: | rest-api |
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
@
2 years ago
- Component Posts, Post Types → Comments
- Description modified (diff)
- Focuses rest-api added
- Keywords changes-requested removed
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
This is in PHP 8.2 and WP 6.6.2, and it shows that you can edit comments to be null.