consistency & simplicity in get_option(), see #12140

git-svn-id: http://svn.automattic.com/wordpress/trunk@14515 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
wpmuguru 2010-05-08 18:05:16 +00:00
parent 235fc1680b
commit 54222465f0
1 changed files with 24 additions and 25 deletions

View File

@ -310,18 +310,13 @@ function get_option( $option, $default = false ) {
if ( defined( 'WP_SETUP_CONFIG' ) )
return false;
if ( ! defined( 'WP_INSTALLING' ) ) {
// prevent non-existent options from triggering multiple queries
if ( defined( 'WP_INSTALLING' ) && is_multisite() ) {
$notoptions = array();
} else {
$notoptions = wp_cache_get( 'notoptions', 'options' );
if ( isset( $notoptions[$option] ) )
return $default;
}
if ( ! defined( 'WP_INSTALLING' ) ) {
$alloptions = wp_load_alloptions();
}
if ( isset( $alloptions[$option] ) ) {
$value = $alloptions[$option];
@ -329,16 +324,11 @@ function get_option( $option, $default = false ) {
$value = wp_cache_get( $option, 'options' );
if ( false === $value ) {
if ( defined( 'WP_INSTALLING' ) )
$suppress = $wpdb->suppress_errors();
$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
if ( defined( 'WP_INSTALLING' ) )
$wpdb->suppress_errors( $suppress );
// Has to be get_row instead of get_var because of funkiness with 0, false, null values
if ( is_object( $row ) ) {
$value = $row->option_value;
if ( ! defined( 'WP_INSTALLING' ) )
wp_cache_add( $option, $value, 'options' );
} else { // option does not exist, so we must cache its non-existence
$notoptions[$option] = true;
@ -347,6 +337,15 @@ function get_option( $option, $default = false ) {
}
}
}
} else {
$suppress = $wpdb->suppress_errors();
$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
$wpdb->suppress_errors( $suppress );
if ( is_object( $row ) )
$value = $row->option_value;
else
return $default;
}
// If home is not set use siteurl.
if ( 'home' == $option && '' == $value )