BuddyDev

Search

Buddypress notifications widget break site with Buddyboss

  • Participant
    Level: Enlightened
    Posts: 30
    Rami Awad on #55715

    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

  • Keymaster
    (BuddyDev Team)
    Posts: 25160
    Brajesh Singh on #55716

    Hi Rami,
    Welcome back.

    Thank you for reporting the issue.
    Please allow me 24 hours to put an update.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 30
    Rami Awad on #55717

    Thank you Brajesh 🙂 You guys are awesome!

  • Keymaster
    (BuddyDev Team)
    Posts: 25160
    Brajesh Singh on #55729

    Hi Rami,
    Thank you.
    It is happening due to a bug in the function

    
    bp_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
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 30
    Rami Awad on #55731

    I 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;

  • Keymaster
    (BuddyDev Team)
    Posts: 25160
    Brajesh Singh on #55734

    Hi Rami,
    Thank you for the reply.

    That would be incorrect solution. It won’t be showing the count correctly.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 30
    Rami Awad on #55735

    Hi 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? Thanks

    Note: BB will not fix it from their side.

  • Keymaster
    (BuddyDev Team)
    Posts: 25160
    Brajesh Singh on #55736

    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

  • Participant
    Level: Enlightened
    Posts: 30
    Rami Awad on #55738

    Yes you are right about BB and the widget 🙂
    FYI, this is happening with all notification widget plugins not just yours!
    Thank you for your support, we did our part!

You must be logged in to reply to this topic.

This topic is: not resolved