Problem/Motivation

It's possible to have multiple comment types, and more than one comment field per node. comment_notify_get_watchers() currently filters by entity ID only, not comment type. If there are comments for more than one comment type for the same entity ID, the thread IDs may clash and 'Replies to my comment' notifications will be sent when they shouldn't be.

e.g. Alice and Bob are commenting on the same node (another insecure way for them to send messages to one another). Alice posts to comment type Foo, then Bob posts to comment type Bar, Bob's comment wasn't actually a reply to Alice, but it will trigger a notification for her should both of them share the same thread (e.g. if they're the very first comments in Foo and Bar for that node, they'll both have thread 01).

Steps to reproduce (deep breath):

  • Create two comment types
  • Add both to a content type - e.g. article
  • Create a node in that content type for testing on
  • Set available subscription modes to 'Replies to my comment' only, not all comments
  • Create two users, e.g. Alice and Bob
  • Have Alice leave a comment in the first comment type (double check her notifications are set to replies), then have Bob leave a comment in the second type. This should trigger the false positive comment notification for Alice.

Proposed resolution

The patch adds an extra WHERE clause to the SQL query in comment_notify_get_watchers in comment_notify.inc. This also necessitates first checking the comment type using the API, and passing this as an extra argument to the function.

Remaining tasks

Patch review by others.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

Prevent false positive notifications for 'Replies to my comment' where more than one comment type used per bundle.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wturrell created an issue. See original summary.

wturrell’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
2.16 KB
gnuget’s picture

Thank you for the patch, It works great!

I wrote a test to make sure this won't happen again.

David.

Status: Needs review » Needs work

The last submitted patch, 3: false_positive_notif-3020673-3.patch, failed testing. View results

gnuget’s picture

Status: Needs work » Needs review
FileSize
5.86 KB

Something went wrong with my last patch (is the same patch of #3 but the last time I used a new tool... and it didn't work, so I used git directly this time)

I just made it again.

  • gnuget committed a2f7604 on 8.x-1.x
    Issue #3020673 by gnuget, wturrell: False positive notifications with...
gnuget’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.