Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/05/2015 06:18:13 PM (9 years ago)
Author:
boonebgorges
Message:

Introduce bp_core_get_root_option() and use throughout BP.

Previously, we referenced the $bp->site_options array directly. This causes
problems in cases where these options may be referenced before the array is
initially populated. bp_core_get_root_option() will fetch the requested
value from the array if it's been populated, and will populate it if it has not.

Fixes #6045.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/functions.php

    r9616 r9698  
    522522
    523523    /**
     524     * @group bp_core_get_root_option
     525     */
     526    public function test_bp_core_get_root_option_with_unpopulated_cache() {
     527        // Back up and unset global cache.
     528        $old_options = buddypress()->site_options;
     529        unset( buddypress()->site_options );
     530
     531        $this->assertSame( $old_options['avatar_default'], bp_core_get_root_option( 'avatar_default' ) );
     532
     533        // Clean up.
     534        buddypress()->site_options = $old_options;
     535    }
     536
     537    /**
     538     * @group bp_core_get_root_option
     539     */
     540    public function test_bp_core_get_root_option_with_populated_cache() {
     541        // Back up and unset global cache.
     542        $old_options = buddypress()->site_options;
     543        buddypress()->site_options = bp_core_get_root_options();
     544        $expected = buddypress()->site_options['avatar_default'];
     545
     546        $this->assertSame( $expected, bp_core_get_root_option( 'avatar_default' ) );
     547    }
     548
     549    /**
    524550     * @group bp_core_add_root_component
    525551     */
Note: See TracChangeset for help on using the changeset viewer.