Skip to:
Content

#3114 closed defect (fixed)

BuddyPress: AJAX subscription links fail

Reported by: r-a-y Owned by: johnjamesjacoby
Milestone: 2.6 Priority: high
Severity: normal Version:
Component: Extend - BuddyPress Keywords: has-patch
Cc:

Description

Reported here:
https://bbpress.org/forums/topic/bbpress-2-6-beta/page/3/#post-184865

There are a few issues with AJAX subscription links under a BuddyPress group:

  1. AJAX call 404s
  2. The localized topic ID is 0 instead of the actual topic ID.

To fix the 404, see 404.patch.

The second issue is more complicated since using wp_localize_script() to set the the topic data is too early to do when on a BuddyPress group topic page. Thus, I would recommend disabling AJAX for subscription links in BuddyPress groups. See no-ajax.patch.

Attachments (7)

3114.404.patch (409 bytes) - added by r-a-y 21 months ago.
3114.no-ajax.patch (1.6 KB) - added by r-a-y 21 months ago.
3114.01.patch (4.5 KB) - added by r-a-y 21 months ago.
3114.02.patch (4.5 KB) - added by r-a-y 21 months ago.
3114.03.patch (4.6 KB) - added by r-a-y 21 months ago.
3114.04.patch (2.8 KB) - added by r-a-y 21 months ago.
3114.05.patch (10.8 KB) - added by johnjamesjacoby 21 months ago.
What it could look like to move everything to data attributes

Download all attachments as: .zip

Change History (14)

@r-a-y
21 months ago

@r-a-y
21 months ago

@r-a-y
21 months ago

@r-a-y
21 months ago

#1 @r-a-y
21 months ago

03.patch adds a data-bbp-nonce attribute to the link and modifies the JS to look for this attribute, which also fixes the problem. Also includes 404.patch.

Disregard 01.patch and 02.patch. Was a little quick on the trigger with those patches!

#2 @johnjamesjacoby
21 months ago

  • Milestone changed from Awaiting Review to 2.6
  • Owner set to johnjamesjacoby
  • Priority changed from normal to high

03 looks great. Thanks @r-a-y!

#3 @johnjamesjacoby
21 months ago

This will either end up in RC 4, or 2.6 proper.

I just tagged the next RC and missed this update.

#4 @johnjamesjacoby
21 months ago

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

In 6538:

BuddyPress: Favorites & Subscriptions AJAX improvements

  • Pass a data attribute along with links
  • Sanitize action key when passed into AJAX action hook
  • Send a 200 response code

This commit allows favorite & subscription links to work with AJAX in BuddyPress group forums pages.

Props r-a-y. Fixes #3114

#5 @r-a-y
21 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

The check needs to be == 0 instead of === 0 because the numeric IDs from wp_localize_script() are a string, so the comparison fails.

The alternative way to fix this is by casting those numeric IDs as integers when doing the check.

@r-a-y
21 months ago

#6 @r-a-y
21 months ago

As discussed on Slack, 04.patch removes the localized nonces in favor of the nonce in the data-bbp-nonce attribute.

@johnjamesjacoby
21 months ago

What it could look like to move everything to data attributes

#7 @johnjamesjacoby
21 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 6541:

BuddyPress: Continuation of r6538.

  • Prefer data attributes
  • Stop passing around localized nonces

Props r-a-y. Fixes #3114.

Note: See TracTickets for help on using tickets.