We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

V3 Comment Moderation Logic Bug

Development and Programming

anthonystauffer's avatar
anthonystauffer
2 posts
7 years ago
anthonystauffer's avatar anthonystauffer

I think there’s a logic bug in the v3 comment moderation code (might not be an issue in v4, but I can’t upgrade yet because addons).

On line 3167 of mod.comments.php, the system tries to determine if the currently logged in user has permission to moderate and/or edit the current comment:

if (ee('Permission')->has('can_edit_all_comments')
      OR (ee('Permission')->has('can_edit_own_comments')
 && $query->row('entry_author_id') == ee()->session->userdata['member_id']))
{
 $can_edit = TRUE;
        $can_moderate = TRUE;
}

So, the code is checking if:

  1. The current user has permission to edit ALL comments OR
  2. The current user can edit his/her OWN comments AND the current ENTRY was authored by this user.

I think this is a bug because the code should be checking if the COMMENT was authored by this user, not the ENTRY.

If a user comments on any article, and the permissions system specifies that members of the group they belong to are allowed to edit their own comments, shouldn’t they be able to edit those comments regardless of who authored the entry they commented on?

Why does the author of the entry have anything to do with whether the currently logged in user is able to edit his/her own comments if the permissions specifically say they are able to do that?

I think this line:

$query->row('entry_author_id') == ee()->session->userdata['member_id']

should be changed to

$query->row('author_id') == ee()->session->userdata['member_id']

so that the system is checking the author of the comment itself, not the entry.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.