Skip to:

Opened 3 years ago

Closed 3 years ago

#8551 closed defect (bug) (wontfix)

PHP Fatal when enabling friends component

Reported by: dcavins's profile dcavins Owned by:
Milestone: Priority: highest
Severity: critical Version:
Component: Friends Keywords: reporter-feedback

Description (last modified by dcavins)

When enabling the friends component from wp-admin/admin.php?page=bp-components, this error is returned:

Fatal error: Uncaught Error: Call to undefined function bp_get_friends_slug() in /Users/cavinsd/Local Sites/bptest/app/public/wp-content/plugins/buddypress/bp-core/bp-core-template.php on line 2414

Attachments (1)

8551.1.diff (813 bytes) - added by dcavins 3 years ago.
Avoid fatals when enabling friends and groups components.

Download all attachments as: .zip

Change History (11)

#1 @dcavins
3 years ago

  • Description modified (diff)

#2 @johnjamesjacoby
3 years ago

  • Milestone changed from 10.0.0 to 9.1.2
  • Priority changed from normal to highest
  • Severity changed from normal to critical

#3 @dcavins
3 years ago

Same is true when enabling groups:
Fatal error: Uncaught Error: Call to undefined function bp_get_groups_slug() in /Users/cavinsd/Local Sites/bptest/app/public/wp-content/plugins/buddypress/bp-core/bp-core-template.php on line 2442

I'm assuming this is because code for the friends and groups components are not loaded when the component is not active. I hate to use function_exists() for something like this, but I'll attach a basic patch.

3 years ago

Avoid fatals when enabling friends and groups components.

#4 @imath
3 years ago

Nothing has changed there lately, this is really weird.

#5 @imath
3 years ago

  • Milestone changed from 9.1.2 to 9.2.0

Milestone renamed

#6 @imath
3 years ago

@dcavins could you share the complete trace for this error, because the function is only used in front-end context (see bp_get_the_body_class()), I'm very surprised WP's body_class() would be used in Admin 🤔

#7 @dcavins
3 years ago

Ah, this error is caused by having the "Query Monitor" plugin activated on my installation:

It does seem like the functions should be prevented from being called when they don't exist, though, so maybe QM just found a curiosity for us.

#8 @imath
3 years ago

As we are using a lot bp_is_active( $component ), we could add a check inside it to make sure the component is fully loaded. Because if we need to check if a function exists each time, bp_is_active( $component_id ) is useless 😬. Maybe you can test adding this into the bp_is_active() function to see if it fixes the issue?

if ( ! did_action( 'bp_' . $component . '_includes' ) ) {
   return false;

PS: there might be problem with PHP Unit tests with this though...

#9 @imath
3 years ago

  • Keywords reporter-feedback added

@dcavins what do you think? Can we consider this as a very rare edge case and close the ticket? Or is a fix needed?

#10 @dcavins
3 years ago

  • Milestone 9.2.0 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Seems ok to me to declare it an edge case. Thanks!

Note: See TracTickets for help on using tickets.