Skip to:
Content

BuddyPress.org

Opened 9 years ago

Closed 9 years ago

#6518 closed defect (bug) (fixed)

"New Comments" activity filter can cause infinite loop

Reported by: r-a-y's profile r-a-y Owned by: r-a-y's profile r-a-y
Milestone: 2.4 Priority: normal
Severity: normal Version: 2.1
Component: Activity Keywords: has-patch commit
Cc:

Description

Since we introduced comment syncing in 2.0, it's possible for activity comments to be attached to 'new_blog_post' activity items.

In #5608, we wanted to expand the "New Comments" activity dropdown filter to include both old-school post comments ('new_blog_comment') and activity comments attached to the 'new_blog_post' activity items.

Here's a case where good intentions went wrong :)

imath discovered that it was possible for an infinite loop to occur when the "New Comments" activity dropdown filter is used.

The bug occurs when attempting to calculate the activity comment depth (#2768).

Since the code in #2768 was meant to calculate the activity comment depth for regular activity updates, this bug never occurred before.

The attached patch checks if the parent activity is not an activity update. If the parent activity is not an activity update, we have reached the top of the tree and can bail from the recursive activity depth check.

This fixes the infinite loop problem.

Props imath for discovering this bug.

Attachments (1)

6518.01.patch (1.5 KB) - added by r-a-y 9 years ago.
Updated to use the correct item_id

Download all attachments as: .zip

Change History (4)

#1 @imath
9 years ago

Thanks a lot r-a-y, just tested it and i confirm it's fixing the issue :)

@r-a-y
9 years ago

Updated to use the correct item_id

#2 @boonebgorges
9 years ago

  • Keywords commit added

Nice catch!

#3 @r-a-y
9 years ago

  • Owner set to r-a-y
  • Resolution set to fixed
  • Status changed from new to closed

In 9961:

Activity: When calculating the activity comment depth, prevent an infinite loop when the parent activity item is not an activity update.

In #2768, we added the ability to calculate the activity comment depth.
The code at the time was meant to calculate the activity comment depth for
regular activity updates ('activity_update'). However, it is possible
for other activity types to have activity comments attached to them. For
example, since the introduction of comment syncing in 2.0, it is now
possible for activity comments to be attached to 'new_blog_post' items.

When fetching activity comments attached to other activity types (as in the
case when using the "New Comments" activity dropdown filter), an infinite
loop can occur while traversing up the activity tree to calculate the
activity comment depth.

This commit fixes this by checking if the parent activity item is not an
activity update during activity comment depth calculation. If the parent
activity is not an activity update, we have reached the top of the tree can
bail from the recursive depth check.

Fixes #6518.

Note: See TracTickets for help on using tickets.