Skip to:
Content

BuddyPress.org

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#5290 closed defect (bug) (fixed)

Getting notifications for a user should check for active components

Reported by: imath's profile imath Owned by: boonebgorges's profile boonebgorges
Milestone: 1.9 Priority: normal
Severity: normal Version: 1.8.1
Component: Toolbar & Notifications Keywords: has-patch 2nd-opinion dev-feedback
Cc:

Description

I was replying to #5289, and i thought what happens if a component is deactivated and user has unread notifications for this component ? For example, i mention a user, then i go into the component settings screen and deactivate the Activity stream component.
In this case, the notifications are displayed to the user in the WP Admin Bar, and clicking on the links doesn't mark the notifications as read.
In WP Admin Bar and in the unread tab of the notifications component, the text displayed is the component_action field of $wpdb->bp_notifications
So the user will have to go in his notifications screen / unread tab to mark or delete each notifications in order to make the WP Admin Bar bubble reset to 0.

So i suggest the attached diff in order to build an array of active components to query on. Even if this array will include components that will never send notifications, it will take care of unread notifications created by a plugin in case the plugin has been deactivated.

This means the plugin to use notifications needs to set himself as an active component, e.g.:
buddypress()->active_components['mypluginid'] = '1';

Attachments (1)

5290.diff (713 bytes) - added by imath 11 years ago.

Download all attachments as: .zip

Change History (8)

@imath
11 years ago

#1 follow-up: @boonebgorges
11 years ago

  • Milestone changed from Awaiting Review to 2.0

Let's look at this for 2.0.

#2 in reply to: ↑ 1 @imath
11 years ago

  • Keywords dev-feedback added

Replying to boonebgorges:

Let's look at this for 2.0.

Boone, i'm sorry to insist, but it's a regression. In 1.8.1, if the component is not active, then the notification is not added in the WP Admin Bar. I'm sorry i should have checked in 1.8.1 before :(
see http://buddypress.trac.wordpress.org/browser/tags/1.8.1/bp-members/bp-members-notifications.php#L107

Although risk is very weak that an administrator deactivate a component once his BuddyPress is set, it's there. So maybe 2.0 might be a bit late, what do you think of keeping an eye on this and maybe add it in to a minor version if feedbacks about this trouble are sent by users ?

#3 @boonebgorges
11 years ago

  • Milestone changed from 2.0 to 1.9

#4 @boonebgorges
11 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 7677:

Don't show notifications from inactive components in admin bar

Inactive components don't have formatting callbacks registered, which means
that those notifications will not be properly formatted. In addition, the
target links of the notifications will 404, with the result that the
notifications will not be marked as read when clicked.

Fixes #5290

Props imath

#6 @johnjamesjacoby
11 years ago

In 7686:

Notifications:

Make buddypress()->active_components the default value for the component_name argument.

This is necessary because notifications are persistent in the database, and active components register callbacks for generating output based on the queried results. If notifications exist for components that are inactive, no callback will be registered, and the output will be empty. By only querying for active components, we can be sure no empty notifications will be displayed to the user.

Reverts r7677. See #5290. Fixes #5300. (trunk)

#7 @johnjamesjacoby
11 years ago

In 7687:

Notifications:

Make buddypress()->active_components the default value for the component_name argument.

This is necessary because notifications are persistent in the database, and active components register callbacks for generating output based on the queried results. If notifications exist for components that are inactive, no callback will be registered, and the output will be empty. By only querying for active components, we can be sure no empty notifications will be displayed to the user.

Reverts r7677. See #5290. Fixes #5300. (1.9 branch)

Note: See TracTickets for help on using tickets.