Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 10 years ago

#5519 closed defect (bug) (fixed)

confusions about BP_Activity_Activity::get_recorded_components() returning recorded components

Reported by: sbrajesh's profile sbrajesh Owned by: boonebgorges's profile boonebgorges
Milestone: 2.0 Priority: low
Severity: minor Version: 2.0
Component: Activity Keywords:
Cc: sbrajesh

Description

Hi,
With the change in BuddyPress 2.0, The last_activity is stored in activity table and recorded under members components. As far as I see there will be only only one entry per user for this members component.

BP_Activity_Activity::get_recorded_components() is returning members as recorded component and if we pass this as object parameter to bp_has_activities function, the result entry shows only the avatar as there is no action or other things are saved for last_activity record.

The problem is, I have been using BP_Activity_Activity::get_recorded_components() to allow users to filter out/include specific actions in my sitewide activity widget. Now, It lists the members as component in BuddyPress 2.0 causing some empty actions for the entry.
I can exclude the members component by some filtering but it may break some other plugins too.

Is it a good idea to return 'members' as recorded component when It will not be used to display any activity and will be used for internal purpose only.

Just wanted some insights from the core developers.
Thank you for looking into it.

Attachments (1)

5519.patch (4.4 KB) - added by boonebgorges 10 years ago.

Download all attachments as: .zip

Change History (5)

#1 @boonebgorges
10 years ago

  • Type changed from enhancement to defect (bug)

sbrajesh - Many thanks for reporting this.

It lists the members as component in BuddyPress 2.0 causing some empty actions for the entry.

Just to clarify: I'm assuming that the empty entries are last_activity entries, since they don't have an activity action callback function. Is this correct?

We didn't catch this because it looks like BP does not use BP_Activity_Activity::get_recorded_components(), except in bp_get_activity_filter_links(), which itself is unused by BP. However, it does appear that you're not the only person using it. See eg https://github.com/search?q=get_recorded_components&ref=cmdform&type=Code.

Since 'last_activity' is the only activity type currently associated with the members component, and since 'last_activity' items aren't fully-fledged activity items for display, I think you're right that it makes sense to remove them by default. But there could be legitimate cases where someone would want them included, so I think it also makes sense to have an argument that lets you get everything.

Could you have a look at 5519.patch? I've written unit tests that I think cover all the relevant cases, but the logic could use another set of eyes.

@boonebgorges
10 years ago

#2 @sbrajesh
10 years ago

  • Keywords reporter-feedback added

boonebgorges - Thank you for looking into it.

Yes, It lists empty actions for the last_activity entries.
You are right about it's removal from core usage. I believe it was removed around 1.2 or 1.5

Here is some good news. I went through all the 48 pages of result. All of the results are for either my plugin bp-sitewide-activity-widget(which people have uploaded on their own) or buddypress(activity class/template file).

So, if we change this at the moment, It won't have any affect on others.
And yes, the patch works nicely. Now it is your call if you think we should have it or not because it will not break anything :)

#3 @boonebgorges
10 years ago

  • Keywords reporter-feedback removed

Thanks for your help, sbrajesh.

#4 @boonebgorges
10 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 8249:

By default, BP_Activity_Activity::get_registered_components() should not return components with only last_activity items

Since moving last_activity items to be stored in the activity database, the
'members' component now has activity associated with it. However, these items
are not "real" activity items, in the sense that you would want to query them
when pulling up an activity stream. BP core has excluded these items from
general activity queries elsewhere. But in BP_Activity_Activity::get_registered_components(),
we continued to return the members component, even when the only activity
items associated with it were of the 'last_activity' variety. Though BP does
not natively use this method anymore, it did break some plugins that were
expecting a more sanitized list of components.

Fixes #5519

Note: See TracTickets for help on using tickets.