Skip to:
Content

bbPress.org

Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#2665 closed defect (bug) (fixed)

bbp_format_buddypress_notifications doesn't return $action when $action !== 'bbp_new_reply'

Reported by: faison's profile Faison Owned by: johnjamesjacoby's profile johnjamesjacoby
Milestone: 2.6 Priority: normal
Severity: normal Version:
Component: Extend - BuddyPress Keywords: has-patch
Cc:

Description

The function bbp_format_buddypress_notifications() is hooked into the filter bp_notifications_get_notifications_for_user. If $action === 'bbp_new_reply', the function will return a proper value. But if $action !== 'bbp_new_reply', it doesn't return anything.

This causes an issue if you have a custom notification action you're trying to format the notification description for:

  • If you hook in before bbp_format_buddypress_notifications() runs, bbp_format_buddypress_notifications() will end up killing your value.
  • If you hook in after bbp_format_buddypress_notifications(), $action will be null because bbp_format_buddypress_notifications() doesn't return anything.

The solution is just to add return $action at the end of the function. I'd include a patch, but I'm having trouble finding the proper documentation to do that.

You can view the function here: https://bbpress.trac.wordpress.org/browser/trunk/src/includes/extend/buddypress/notifications.php#L41

Thanks,
Faison

Attachments (1)

2665.patch (437 bytes) - added by Faison 10 years ago.

Download all attachments as: .zip

Change History (6)

#1 @netweb
10 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 2.6

Thanks for the ticket, do want to create the patch? If so here are some bits to help get started :)

To get started and learn about how to create a patch that is in the format we use here (and the entire WordPress Trac ecosystem) here are a couple of docs to get you on your way:

The bbPress SVN repo is http://bbpress.svn.wordpress.org/trunk

@Faison
10 years ago

#2 @Faison
10 years ago

  • Keywords has-patch added; needs-patch removed

Hi netweb,

Thanks for the links! I don't know why, but I just couldn't find that SVN repo url.

Anyways, I attached a patch that does exactly what I stated above: adds return $action; to the bottom of the function.

Thanks,
Faison

#3 @johnjamesjacoby
10 years ago

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

In 5512:

Slightly refactor bbp_format_buddypress_notifications():

  • Return original $action if not bbp_new_reply.
  • Reduce indentation to accommodate new $action check.

This fixes a bug where checking for new reply notifications could cause future notification filter checks to fail.

Props Faison. Fixes #2665.

#4 @colabsadmin
8 years ago

Why wait until 2.6 to add this fix? It took me over and hour to figure out why my custom notification wasn't displaying correctly.

#5 @likebtn
8 years ago

When bbPress 2.6 is going to be released?

Note: See TracTickets for help on using tickets.