Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#4914 closed enhancement (fixed)

BP_Groups_Component->setup_globals should use $bp->site_options

Reported by: wpdennis's profile wpdennis Owned by: boonebgorges's profile boonebgorges
Milestone: 1.8 Priority: normal
Severity: normal Version:
Component: Groups Keywords: has-patch
Cc:

Description

In BP_Core->setup_globals() the site options are loaded into $bp->site_options.

BP_Groups_Component->setup_globals() uses bp_get_option to decide whether avatar uploads are enabled or not:

// If avatar uploads are not disabled, add avatar option
if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) ) {
	$this->group_creation_steps['group-avatar'] = array(
		'name'     => __( 'Avatar',   'buddypress' ),
		'position' => 20
	);
}

I'm not 100% sure on this, but shouldn't it be possible to use $bp->site_options instead of bp_get_option() like:

// If avatar uploads are not disabled, add avatar option
if ( !(int)$bp->site_options['bp-disable-avatar-uploads'] ) {

Or, maybe, bp_get_option() should check if the needed value is already loaded. Something like:

function bp_get_option( $option_name, $default = '' ) {
	$bp = buddypress();

	$value = array_key_exists($option_name, $bp->site_options) 
		? $bp->site_options[$option_name]
		: get_blog_option( bp_get_root_blog_id(), $option_name, $default );

	return apply_filters( 'bp_get_option', $value );
}

What do you think?

Change History (3)

#1 @boonebgorges
12 years ago

  • Keywords has-patch added; dev-feedback removed
  • Milestone changed from Awaiting Review to 1.8

This is definitely a problem.

bp_get_option() should check if the needed value is already loaded

This is overly broad, and might cause name clashes.

We should be doing something closer to your first suggestion: finding the spots where we use bp_get_option() to fetch a value that we've already cached in site_options.

#2 @boonebgorges
12 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 6936:

When populating group_creation_steps, use cached disable-avatar setting

Calling bp_get_option() to retrieve a value that has already been cached in
BP's main bootstrap can cause unreasonable overhead on multisite setups.

Fixes #4914

Props wpdennis

#3 @boonebgorges
12 years ago

FYI, I've added a ticket #4945 that addresses part of this problem more broadly.

Note: See TracTickets for help on using tickets.