Skip to:
Content

BuddyPress.org

Opened 6 years ago

Closed 6 years ago

#7951 closed defect (bug) (fixed)

Nouveau: bp_get_suggestions 400 error when activity component is disabled

Reported by: shubh14's profile shubh14 Owned by: boonebgorges's profile boonebgorges
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.0.0
Component: Templates Keywords: has-patch 2nd-opinion
Cc:

Description

Hi,

I am getting the 400 error when I type in a @username to send a private message when the activity component is disabled. The exact error is:

Failed to load resource: the server responded with a status of 400 () /wp-admin/admin-ajax.php?action=bp_get_suggestions&term=arun&type=members

Wordpress: 4.9.8
Buddypress: 3.1.0
Theme: Nouveau

Attachments (3)

bp-error.jpg (196.6 KB) - added by shubh14 6 years ago.
7951.01.patch (2.0 KB) - added by r-a-y 6 years ago.
7951.02.patch (2.5 KB) - added by imath 6 years ago.
Moves bp_ajax_get_suggestions() into src/bp-core/bp-core-functions.php

Download all attachments as: .zip

Change History (10)

@shubh14
6 years ago

#1 @r-a-y
6 years ago

  • Component changed from Messages to Templates
  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 3.3.0
  • Summary changed from bp_get_suggestions 400 error when activity component is disabled to Nouveau: bp_get_suggestions 400 error when activity component is disabled

Confirmed.

The problem is the mentions script is always loaded without checking if the Activity component is active or not.

01.patch is a potential fix for this. @imath, can you take a look when you have a chance?

@r-a-y
6 years ago

#2 @imath
6 years ago

  • Keywords 2nd-opinion added

Thanks for the ping @r-a-y I think a better fix would be to make sure the bp_ajax_get_suggestions() is available even if the activity component is not active, otherwise it's not possible to autocomplete usernames in the message compose UI.

I'd probably move this function into bp-core/bp-core-functions.php just after the bp_core_get_suggestions() one. As i don't see any functions needing the bp-activity/bp-activity-functions.php to be loaded into bp_ajax_get_suggestions(), I think there's no problem doing so.

@DJPaul what do you think ?

@imath
6 years ago

Moves bp_ajax_get_suggestions() into src/bp-core/bp-core-functions.php

#3 @r-a-y
6 years ago

It makes sense that bp_ajax_get_suggestions() should be moved to core since bp_core_get_suggestions() is already apart of core.

It might also make sense to register the mentions JS in core as well. That way, the Activity component or Nouveau can enqueue it when it wants. Right now, Nouveau has to manually re-enqueue it.

#4 @DJPaul
6 years ago

The Suggestions stuff was architectured to support more than what we've used it for. Recall that BP_Groups_Member_Suggestions exists in/for the Groups component.

Ray's patch looks a good approach. I like that Mathieu's patch also checks to see if the global variable is present. I like these combined.

Ray's idea about registering this in bp_core_register_common_scripts() -- that makes sense, but let's not re-arrange any related existing wp_enqueue_script call apart from the duplication in the Nouveau templates.

Version 0, edited 6 years ago by DJPaul (next)

#5 @DJPaul
6 years ago

  • Milestone changed from 3.3.0 to 4.0

#6 @boonebgorges
6 years ago

In 12286:

Move bp_ajax_get_suggestions() handler to Core component.

It was previously located in the Activity component, which made it
impossible to do an AJAX suggestions query (such as in the case of
Messages) when Activity was disabled.

Props imath.

See #7951.

#7 @boonebgorges
6 years ago

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

In 12287:

Nouveau: Bail out of Messages autocomplete if suggest library is absent.

This is a safety measure, in case suggest is unloaded for some reason.

Props r-a-y.
Fixes #7951.

Note: See TracTickets for help on using tickets.