Opened 4 years ago
Closed 4 years ago
#8551 closed defect (bug) (wontfix)
PHP Fatal when enabling friends component
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | highest | |
| Severity: | critical | Version: | |
| Component: | Friends | Keywords: | reporter-feedback |
| Cc: |
Description (last modified by )
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)
Change History (11)
#2
@
4 years ago
- Milestone changed from 10.0.0 to 9.1.2
- Priority changed from normal to highest
- Severity changed from normal to critical
#6
@
4 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
@
4 years ago
Ah, this error is caused by having the "Query Monitor" plugin activated on my installation:
bp_is_user_friends_activity()
wp-content/plugins/query-monitor/collectors/conditionals.php:88
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
@
4 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...
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 2442I'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.