Investigation
A client of mine wanted to disable the activity stream, went to Dashboard > Settings > BuddyPress > Components > Activity Streams, and Unticked the option. After they hit save, the site displayed the error ‘There has been a critical error on this website’ and the entire website (including admin dashboard) was unreachable/unusable (only returning this error). Under the hood, I found the error was “Fatal error: Uncaught Error: Class ‘BBP_BuddyPress_Activity’ not found”.
WordPress version: 5.7
bbPress Version 2.6.6
So I enabled debugging info in the wp-config.php file and received the full error (paths sanitized for security):
Fatal error: Uncaught Error: Class 'BBP_BuddyPress_Activity' not found in public_html/wp-content/plugins/bbpress/includes/extend/buddypress/loader.php:153 Stack trace: 0 public_html/wp-includes/class-wp-hook.php(292): BBP_Forums_Component->setup_components('') 1 public_html/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters(NULL, Array) 2 public_html/wp-includes/plugin.php(484): WP_Hook->do_action(Array) 3 public_html/wp-content/plugins/buddypress/bp-core/bp-core-dependency.php(267): do_action('bp_init') 4 public_html/wp-includes/class-wp-hook.php(292): bp_init('') 5 public_html/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters(NULL, Array) 6 public_html/wp-includes/plugin.php(484): WP_Hook->do_action(Array) 7 public_html/wp-settings.php(560): do_action('init') 8 public_html/wp-co in public_html/wp-content/plugins/bbpress/includes/extend/buddypress/loader.php on line 153
Because of the last line, I checked Line 153 of loader.php (as referenced above), which brought me to the ‘setup_components()’ function. Line 153 is the ‘new BBP_BuddyPress_Activity() line.
/**
* Instantiate classes for BuddyPress integration
*
* @since 2.0.0 bbPress (r3395)
*/
public function setup_components() {
// Always load the members component
bbpress()->extend->buddypress->members = new BBP_BuddyPress_Members();
// Create new activity class
if ( bp_is_active( 'activity' ) ) {
bbpress()->extend->buddypress->activity = new BBP_BuddyPress_Activity();
}
// Register the group extension only if groups are active
if ( bbp_is_group_forums_active() && bp_is_active( 'groups' ) ) {
bp_register_group_extension( 'BBP_Forums_Group_Extension' );
}
}
Resolution
From this, I was able to determine that bbPress thought the ‘Activity’ component was enabled, but for some reason did not have the ‘BBP_BuddyPress_Activity’ class loaded. I was able to temporarily resolve the issue by patching the ‘setup_components()’ function in the file ‘wp-content/plugins/bbpress/includes/extend/buddypress/loader.php’ with a few lines in order to manually include the ‘BBP_BuddyPress_Activity’ class if necessary:
// Create new activity class
if ( bp_is_active( 'activity' ) ) {
// Temporary patch!
if ( ! class_exists( 'BBP_BuddyPress_Activity' ) ){
require_once(dirname(__FILE__).'/activity.php');
}
bbpress()->extend->buddypress->activity = new BBP_BuddyPress_Activity();
}
As I have patched a file within the plugin, it will be overwritten if any upgrades come out for the plugin. Because of that, I have opened a ticket in the bbPress Trac system to look for a final resolution that will survive plugin upgrades (hopefully through an update to the bbPress plugin itself).