Skip to:
Content

BuddyPress.org

Opened 8 years ago

Closed 8 years ago

#7951 closed defect (bug) (fixed)

Nouveau: bp_get_suggestions 400 error when activity component is disabled

Reported by: shubh14 Owned by: boonebgorges
Priority: normal Milestone: 4.0
Component: Templates Version: 3.0.0
Severity: normal 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 8 years ago.
7951.01.patch (2.0 KB ) - added by r-a-y 8 years ago.
7951.02.patch (2.5 KB ) - added by imath 8 years ago.
Moves bp_ajax_get_suggestions() into src/bp-core/bp-core-functions.php

Download all attachments as: .zip

Change History (10)

@shubh14
8 years ago

#1 @r-a-y
8 years ago

  • Component MessagesTemplates
  • Keywords has-patch added
  • Milestone Awaiting Review3.3.0
  • Summary bp_get_suggestions 400 error when activity component is disabledNouveau: 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
8 years ago

#2 @imath
8 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
8 years ago

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

#3 @r-a-y
8 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
8 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 de-duplication in the Nouveau templates.

Last edited 8 years ago by DJPaul (previous) (diff)

#5 @DJPaul
8 years ago

  • Milestone 3.3.04.0

#6 @boonebgorges
8 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
8 years ago

  • Owner set to boonebgorges
  • Resolutionfixed
  • Status newclosed

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.