Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/29/2016 08:28:53 PM (8 years ago)
Author:
r-a-y
Message:

Core: In our class autoloader, check if the component is active before attempting to include it.

In #6853, we introduced class autoloading to help reduce the amount of
memory used by BuddyPress on any given page request.

This caused a problem in some BuddyPress plugins that previously relied on
a class_exists() check to determine if a BuddyPress component is active
or not. For example, if ( class_exists( 'BP_Group_Extension' ) ) {}.

In BuddyPress 2.6.0, class_exists( 'BP_Group_Extension' ) will now return
true all the time by default. In some instances, this can cause a fatal
error if the Groups component is disabled.

This commit adds a component check before including the class, while
allowing core classes and PHPUnit to load as usual.

Plugin developers should read the following development post for more
details:
https://bpdevel.wordpress.com/2016/06/28/class-autoloading-and-what-this-means-for-plugin-developers/

Fixes #7140 (2.6-branch).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/src/bp-loader.php

    r10900 r10918  
    618618        }
    619619
     620        // Sanity check 2 - Check if component is active before loading class.
     621        // Skip if PHPUnit is running.
     622        if ( 'core' !== $component && false === bp_is_active( $component ) && false === function_exists( 'tests_add_filter' ) ) {
     623            return;
     624        }
     625
    620626        require $path;
    621627    }
Note: See TracChangeset for help on using the changeset viewer.