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 | Owned by: | 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)
Change History (5)
#2
@
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 :)
sbrajesh - Many thanks for reporting this.
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 inbp_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.