Hi 🙂
once a notification is received the site breaks, can it be fixed to work with Buddyboss? Thanks
PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value)
must be of type Countable|array, stdClass given in
/public_html/wp-content/plugins/buddypress-notifications-widget/
core/class-bp-notification-widget.php:52
Hi Rami,
Welcome back.Thank you for reporting the issue.
Please allow me 24 hours to put an update.Regards
BrajeshHi Rami,
Thank you.
It is happening due to a bug in the functionbp_notifications_get_notifications_for_user
in BuddyBoss.
They need to change this
// Calculate a renderable output for each notification type. foreach ( $notifications as $notification_item ) { $renderable = bb_notification_get_renderable_notifications( $notification_item, $format, 'web' ); }
to
$renderable = array(); // Calculate a renderable output for each notification type. foreach ( $notifications as $notification_item ) { $renderable[] = bb_notification_get_renderable_notifications( $notification_item, $format, 'web' ); }
Please report it to them.
Regards
BrajeshI don’t think BuddyBoss will apply the update but I will report it anyway.
We fixed it this way thou:
File Path => buddypress-notifications-widget/core/class-bp-notification-widget.php
Line : 52
// $count = count( $notifications );
$count = $notifications->total_count ?? 0;Hi Rami,
Thank you for the reply.That would be incorrect solution. It won’t be showing the count correctly.
Regards
BrajeshHi Brajesh,
IF this line 43: $notifications = bp_notifications_get_notifications_for_user( $user_id, $format );
So this is returning notifications for specific user. In that object {$notifications->total_count} , which means this is correct count.
Please explain why its not correct count? ThanksNote: BB will not fix it from their side.
Hi Rami,
The count should always be 1 if you do that.The problem is with the intent of the function. It is supposed to return an array of notification objects or rendered notification strings.They have too many bugs in that implementation. If it is a conscious decision to not fix bug, it is their call.
Regards
Brajesh
You must be logged in to reply to this topic.