[wp-trac] [WordPress Trac] #62066: Weird ability to modify comments to be empty
WordPress Trac
noreply at wordpress.org
Wed Sep 18 00:58:17 UTC 2024
#62066: Weird ability to modify comments to be empty
--------------------------+------------------------------
Reporter: lbones | Owner: Lela Bones
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version: 6.6.2
Severity: minor | Resolution:
Keywords: needs-patch | Focuses: rest-api
--------------------------+------------------------------
Changes (by sabernhardt):
* keywords: needs-patch changes-requested => needs-patch
* focuses: => rest-api
* component: Posts, Post Types => Comments
Old description:
> When I was viewing [this](https://core.trac.wordpress.org/ticket/61244)
> ticket, 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 [this file](https://github.com/WordPress
> /wordpress-develop/blob/trunk/src/wp-includes/rest-api/endpoints/class-
> wp-rest-comments-controller.php#L424) 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 the update_item function would resolve this issue.
New description:
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 [https://github.com/WordPress/wordpress-
develop/blob/5d0753bb6e7c29adc8e6171ee21338cb5ade297b/src/wp-includes
/rest-api/endpoints/class-wp-rest-comments-controller.php#L568
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.
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62066#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list