Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/02/2013 10:36:10 PM (11 years ago)
Author:
boonebgorges
Message:

Bail out of loading buddypress-functions.php if $wp_query is not set

When $wp_query is not set, it means either that the main query has not run,
or that it has been somehow wiped out. Having an empty $wp_query global causes
problems in load_template() (used to load buddypress-functions.php()) because
of the way load_template() populates certain global variables from $wp_query.

An empty $wp_query global should not happen during normal page loads, but does
happen sometimes during unit testing, when globals are directly manipulated by
the bootstrap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-template-loader.php

    r7452 r7508  
    398398 */
    399399function bp_load_theme_functions() {
    400     global $pagenow;
     400    global $pagenow, $wp_query;
    401401
    402402    // do not load our custom BP functions file if theme compat is disabled
     
    408408    if ( bp_is_deactivation() )
    409409        return;
     410
     411    // If the $wp_query global is empty (the main query has not been run,
     412    // or has been reset), load_template() will fail at setting certain
     413    // global values. This does not happen on a normal page load, but can
     414    // cause problems when running automated tests
     415    if ( ! is_a( $wp_query, 'WP_Query' ) ) {
     416        return;
     417    }
    410418
    411419    // Only include if not installing or if activating via wp-activate.php
Note: See TracChangeset for help on using the changeset viewer.