#4914 closed enhancement (fixed)
BP_Groups_Component->setup_globals should use $bp->site_options
Reported by: | wpdennis | Owned by: | 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)
Note: See
TracTickets for help on using
tickets.
This is definitely a problem.
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
.