Skip to:

Opened 3 months ago

Last modified 3 months ago

#8556 new defect (bug)

BP_Notifications_Notification::get - error for meta_query

Reported by: shawfactor Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Core Keywords:


Team I have identified an error with BP_Notifications_Notification::get

When you do a meta query using the above static method the notifciation id is no longer avilable in the result as it won't cast as an integer

my code:

$meta_query = array(


'key' => 'foo_key',
'compare' => 'NOT EXISTS',


$args = array(

'user_id' => $user_ids_array,
'meta_query' => $meta_query,
'per_page' => '1',
'order_by' => 'date_notified',

$notifications = BP_Notifications_Notification::get($args);

ithe issue saeems to be that it won't cats as an integer on line

$results[$key]->id = (int) $results[$key]->id;

Change History (2)

#1 @shawfactor
3 months ago

actually the problem is caused by the join which creates two id fields in the result. The fix is quite easy.

Simply change the original select statement to


$select_sql = "SELECT n.*";

So that only the $bp->notifications->table_name fields are selected

#2 @shawfactor
3 months ago

actually fixing this also reqauires pathing the method get_where_sql in the same class to ensure that id is never ambiguous

Version 0, edited 3 months ago by shawfactor (next)
Note: See TracTickets for help on using tickets.