Reduce DB queries by half during MU signup, props donncha, see #12140

git-svn-id: http://svn.automattic.com/wordpress/trunk@12973 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
wpmuguru 2010-02-05 17:59:24 +00:00
parent a7e2f2533b
commit 908a280df4
1 changed files with 42 additions and 30 deletions

View File

@ -335,7 +335,9 @@ function get_option( $setting, $default = false ) {
return $default;
}
if ( ! defined( 'WP_INSTALLING' ) ) {
$alloptions = wp_load_alloptions();
}
if ( isset( $alloptions[$setting] ) ) {
$value = $alloptions[$setting];
@ -495,6 +497,7 @@ function update_option( $option_name, $newvalue ) {
$newvalue = maybe_serialize( $newvalue );
do_action( 'update_option', $option_name, $oldvalue, $newvalue );
if ( ! defined( 'WP_INSTALLING' ) ) {
$alloptions = wp_load_alloptions();
if ( isset( $alloptions[$option_name] ) ) {
$alloptions[$option_name] = $newvalue;
@ -502,6 +505,7 @@ function update_option( $option_name, $newvalue ) {
} else {
wp_cache_set( $option_name, $newvalue, 'options' );
}
}
$wpdb->update($wpdb->options, array('option_value' => $newvalue), array('option_name' => $option_name) );
@ -560,6 +564,7 @@ function add_option( $name, $value = '', $deprecated = '', $autoload = 'yes' ) {
$value = maybe_serialize( $value );
$autoload = ( 'no' === $autoload ) ? 'no' : 'yes';
do_action( 'add_option', $name, $value );
if ( ! defined( 'WP_INSTALLING' ) ) {
if ( 'yes' == $autoload ) {
$alloptions = wp_load_alloptions();
$alloptions[$name] = $value;
@ -567,6 +572,7 @@ function add_option( $name, $value = '', $deprecated = '', $autoload = 'yes' ) {
} else {
wp_cache_set( $name, $value, 'options' );
}
}
// This option exists now
$notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh
@ -606,6 +612,7 @@ function delete_option( $name ) {
do_action( 'delete_option', $name );
// expected_slashed ($name)
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name = '$name'" );
if ( ! defined( 'WP_INSTALLING' ) ) {
if ( 'yes' == $option->autoload ) {
$alloptions = wp_load_alloptions();
if ( isset( $alloptions[$name] ) ) {
@ -615,6 +622,7 @@ function delete_option( $name ) {
} else {
wp_cache_delete( $name, 'options' );
}
}
do_action( 'deleted_option', $name );
return true;
}
@ -665,6 +673,7 @@ function get_transient($transient) {
if ( $_wp_using_ext_object_cache ) {
$value = wp_cache_get($transient, 'transient');
} else {
if ( ! defined( 'WP_INSTALLING' ) ) {
$transient_option = '_transient_' . esc_sql($transient);
// If option is not in alloptions, it is not autoloaded and thus has a timeout
$alloptions = wp_load_alloptions();
@ -676,6 +685,7 @@ function get_transient($transient) {
return false;
}
}
}
$value = get_option($transient_option);
}
@ -1742,7 +1752,9 @@ function is_blog_installed() {
return true;
$suppress = $wpdb->suppress_errors();
if ( ! defined( 'WP_INSTALLING' ) ) {
$alloptions = wp_load_alloptions();
}
// If siteurl is not set to autoload, check it specifically
if ( !isset( $alloptions['siteurl'] ) )
$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );