Skip to:
Content

BuddyPress.org

Opened 4 years ago

Closed 4 years ago

#6323 closed enhancement (fixed)

Unable to get user ID of activity items before they are deleted

Reported by: johnjamesjacoby Owned by:
Milestone: 2.3 Priority: high
Severity: normal Version: 1.1
Component: Activity Keywords:
Cc:

Description

When deleting an activity stream item, it's not possible to get any relevant data about those items before they are deleted from the database.

Our existing implementation does pass the activity ID's themselves around, and calls to bp_activity_delete() do have before & after actions for execution, but all those allow for is seeing what the query parameters are for the items being deleted, and they do not relay back anything about the actual items themselves.

What I'm trying to do:

  • Keep a count of activity stream updates per user
  • When an activity item is deleted, check the user ID and flush the cached count for the activity author

This is not currently possible because there is no way to intercept the deletion request, and the person deleting the activity might not be the same user that posted it, so the existing $user_id checks do not help (and may tangentially be broken anyways.)

Attachments (2)

6323.01.patch (7.0 KB) - added by johnjamesjacoby 4 years ago.
6323.02.patch (1.0 KB) - added by JustinSainton 4 years ago.

Download all attachments as: .zip

Change History (10)

#1 @johnjamesjacoby
4 years ago

A few improvements to BP_Activity_Activity::delete() will fix this:

  • Select * instead of id
  • wp_list_pluck() the ID's out of the results
  • do_action_ref_array() on the array of activity items about to be deleted
  • Recursively call BP_Activity_Activity::delete() on all activity comments so this action is repeatedly fired correctly
  • Get rid of the extract() call while we are in there
  • Note that BP_Activity_Activity ::delete_activity_item_comments() is not used. This method is from the olden days of Activity, before the mptt approach and when comments were part of the Wire component.

#2 @boonebgorges
4 years ago

  • Keywords needs-patch needs-unit-tests added

#3 @johnjamesjacoby
4 years ago

In 9651:

Activity: Increase test coverage for delete group.

Includes tests for:

  • Delete by id
  • Delete by type
  • Delete by component
  • Delete by user_id
  • Delete item & comments
  • Delete item, comments, & meta
  • Delete item meta
  • Delete all item meta (legacy)

See #6323.

#4 @johnjamesjacoby
4 years ago

In 9652:

Activity: Improvements to BP_Activity_Activity::delete():

  • Select * instead of id on about-to-be-deleted activity items
  • wp_list_pluck() the ID's out of the total results for backwards compatibility
  • Introduce before/after actions on array of activity items about to be deleted
  • Recursively call BP_Activity_Activity::delete() on activity comments so new actions are fired on them
  • Remove extract() usage in place of $r array convention

See #6323.

#5 @JustinSainton
4 years ago

6323.02.patch adds a few little inline doc typo fixes.

#6 @johnjamesjacoby
4 years ago

In 9653:

Activity: Grammatical fixes to r9652. Props JustinSainton. See #6323.

#7 @DJPaul
4 years ago

@johnjamesjacoby Is this ticket done?

#8 @johnjamesjacoby
4 years ago

  • Keywords needs-patch needs-unit-tests removed
  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.