Skip to:
Content

bbPress.org

Opened 7 years ago

Closed 6 days ago

#3360 closed defect (bug) (fixed)

Conflict in bbp_unsubscribe action with Buddypress

Reported by: SirLouen Owned by:
Priority: normal Milestone: 2.6.20
Component: API - Subscriptions Version: trunk
Severity: normal Keywords: has-patch
Cc: tanner, m

Description

By default, bbp_unsubscribe action works fine both AJAX and link versions

For example:
The subscribe button on top of a forum is an AJAX version
The unsubscribe button in the "subscription" section within a user profile is a link version

By installing Buddypress the AJAX version works fine, but the link version breaks

This can be tested after installing Buddypress by subscribing to a forum and trying to unsubscribe by using the current nonce and the forum ID using the full URL with the adequate parameters (or just by going to the ->members->forums->subscription and trying to unsubscribe by pressing the button.

?action=bbp_unsubscribe&object_id=xxx&object_type=post&_wpnonce=xxxxxxxx

Attachments (1)

bbp-buddypress-subscription-fix.patch​ (581 bytes ) - added by tanner m 18 months ago.

Download all attachments as: .zip

Change History (5)

#1 @tanner m
18 months ago

  • Cc tanner m added
  • Keywords has-patch added; needs-patch removed

I've identified the issue and created a patch that fixes the problem.

Issue Description

The subscription system in bbPress has two ways of handling unsubscribe actions:

  1. AJAX-based subscribe / unsubscribe (works with BuddyPress, per the original issue description)
  2. Link-based subscribe / unsubscribe (breaks with BuddyPress)

The problem occurs because BuddyPress passes the action parameter differently than standard bbPress. In the bbp_subscriptions_handler() function, BuddyPress doesn't pass any parameters via the bp_actions hook - so we need to look it up in the $_GET parameter. When a user clicks the subscribe / unsubscribe link in their profile, the function receives an empty $action parameter and cannot determine what action to take.

Solution

The fix is simple: we check for the action in $_GET when the function's $action parameter is empty. This maintains compatibility with the standard bbPress implementation while also supporting BuddyPress's implementation.

// BuddyPress doesn't send the $action parameter, so we need to check for it
if ( empty( $action ) && isset( $_GET['action'] ) && is_string( $_GET['action'] ) ) {
    $action = sanitize_key( $_GET['action'] );
}

Testing

I've verified this fix works by:

  1. Setting up a test environment with BuddyPress installed
  2. Verifying the subscribe / unsubscribe link in user profiles now works correctly with this patch

I've attached the patch file for review. This is a minimal change with no side effects to standard bbPress functionality.

#2 @johnjamesjacoby
9 days ago

  • Milestone Awaiting Review → 2.6.20

#3 @johnjamesjacoby
6 days ago

Thank you, @SirLouen, for reporting this, and thank you, @tanner-m, for the patch and testing. Sorry I missed the connection earlier.

This was fixed in [7933] while addressing #3454, then backported to the 2.6 branch in [7934]. The BuddyPress engagement handler now reads the request action before passing it to the existing favorites and subscriptions handlers, which covers the profile unsubscribe failure reported here.

#4 @johnjamesjacoby
6 days ago

  • Resolution → fixed
  • Status new → closed
Note: See TracTickets for help on using tickets.