[buddypress-trac] [BuddyPress Trac] #6669: Blank notifications when using the bp_notifications_get_notifications_for_user filter hook

buddypress-trac noreply at wordpress.org
Sat Oct 17 21:29:24 UTC 2015


#6669: Blank notifications when using the
bp_notifications_get_notifications_for_user filter hook
---------------------------------------+-----------------------------
 Reporter:  henry.wright               |      Owner:
     Type:  defect (bug)               |     Status:  new
 Priority:  normal                     |  Milestone:  Awaiting Review
Component:  Component - Notifications  |    Version:  2.3.3
 Severity:  normal                     |   Keywords:
---------------------------------------+-----------------------------
 I've come across a strange problem with the
 {{{bp_notifications_get_notifications_for_user}}} filter hook which causes
 admin bar notifications to be blank. Ref:
 https://github.com/buddypress/BuddyPress/blob/master/src/bp-notifications
 /bp-notifications-functions.php#L282

 '''Steps to reproduce the problem'''

 Step 1: Filter active components so that 2 are added:

 {{{
 function step_1( $component_names, $active_components ) {
     $component_names[] = 'my_first_component';
     $component_names[] = 'my_second_component';
     return $component_names;
 }
 add_filter( 'step_1', 'crowdmentions_get_registered_components', 10, 2 );
 }}}

 Step 2: Now try to use the {{{bp_notifications_get_notifications_for_user
 }}}filter twice like this:
 {{{
 function step_2a( $component_action, $item_id, $secondary_item_id,
 $item_count, $format = 'string' ) {
     if ( $component_action === 'my_first_component' ) {
         // Do something making sure to return the appropriate type (array
 in this case).
     }
 }
 add_filter( 'bp_notifications_get_notifications_for_user', 'step_2a', 10,
 5 );
 }}}
 {{{
 function step_2b( $component_action, $item_id, $secondary_item_id,
 $item_count, $format = 'string' ) {
     if ( $component_action === 'my_second_component' ) {
         // Do something making sure to return the appropriate type (array
 in this case).
     }
 }
 add_filter( 'bp_notifications_get_notifications_for_user', 'step_2b', 10,
 5 );
 }}}

 You should see blank notifications.

 To the best of my knowledge, it is happening because either
 {{{step_1a()}}} or {{{step1b()}}} will always return NULL which means the
 value of {{{$content}}} back inside
 {{{bp_notifications_get_notifications_for_user()}}} will also be NULL at
 some point.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6669>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list