Skip to:
Content

BuddyPress.org

Changeset 10919


Ignore:
Timestamp:
06/29/2016 08:29:47 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 (trunk).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-loader.php

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