Opened 6 years ago
Last modified 8 months ago
#3360 new defect (bug)
Conflict in bbp_unsubscribe action with Buddypress
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | trunk |
| Component: | API - Subscriptions | 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
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:
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 thebp_actionshook - 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
$_GETwhen the function's$actionparameter 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:
I've attached the patch file for review. This is a minimal change with no side effects to standard bbPress functionality.