Opened 10 years ago
Closed 10 years ago
#6099 closed defect (bug) (fixed)
groups/favorites/friends activity scopes when displayed user has not any 'scope' items
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.2 | Priority: | high |
Severity: | major | Version: | |
Component: | Activity | Keywords: | has-patch commit |
Cc: |
Description
We have a trouble in adjusting scopes for BP_Activity_Activity::get_scope_query_sql
when the displayed user does not have any items in the active scope. In this case all user's activities are fetched instead of none.
Way to reproduce for the favorites
scope for instance : simply make sure the displayed user has not favorited any items.
I've built unit tests and realized it's also appearing on groups and friends scopes.
To solve this i suggest to set dummy arrays having a 0
value as the item id when the user is not a part of any groups/did not favorited any activities or has no friends.
Attachments (2)
Change History (8)
This ticket was mentioned in Slack in #buddypress by imath. View the logs.
10 years ago
#3
@
10 years ago
Nice catch, imath!
I forgot to port over no results from my feature-as-a-plugin. In my plugin, I used a no-results clause like in no-results.patch
. But based on the way that custom scopes are handled in each respective scope filter function, I can understand the approach in 6099.patch
as well.
IMO, both patches are about equal when it comes to debugging.
If I were debugging the activity query's WHERE
conditions and saw this:
[scope_query_sql] => ( ( a.component = 'groups' AND a.item_id IN ( 0 ) ) )
I would wonder where a.item_id IN ( 0 )
came from.
Whereas, this might be more explicit:
[scope_no_results] => 0 = 1
Happy to go with either patch.
#4
@
10 years ago
- Owner set to r-a-y
- Resolution set to fixed
- Status changed from new to closed
In 9330:
These fixes look correct to me. There was some discussion https://wordpress.slack.com/archives/buddypress/p1420808854002450 about whether
array( 0 )
is hackish, but IMO it is not - I think it's the right way to solve this. (The alternative would be to introduce a0=1
type no-results clause, but the way that we build our SQL makes this difficult to do in a consistent way across components. Thearray( 0 )
fix is much more straightforward, and I'd argue more semantically correct when it comes time to debug.)