From 5b9af382caaefe84e5df766882d6c07a5a55df29 Mon Sep 17 00:00:00 2001 From: donncha Date: Mon, 22 Sep 2008 11:22:33 +0000 Subject: Use default value for get_options() get *all* options, not just auto load options, thanks Will Norris git-svn-id: http://svn.automattic.com/wordpress-mu/branches/2.6@1489 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-includes/functions.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 261097e..d66e275 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -319,7 +319,7 @@ function is_serialized_string( $data ) { * @param string $setting Name of option to retrieve. Should already be SQL-escaped * @return mixed Value set for the option. */ -function get_option( $setting ) { +function get_option( $setting, $default = false ) { global $wpdb, $switched, $current_blog; $wpdb->hide_errors(); @@ -330,7 +330,7 @@ function get_option( $setting ) { $value = _get_option_cache( $setting ); if ( false === $value ) - return false; + return $default; // If home is not set use siteurl. if ( 'home' == $setting && '' == $value ) @@ -392,13 +392,13 @@ function form_option( $option ) { * @return array List of all options. */ function get_alloptions() { - global $wpdb, $wp_queries; + global $wpdb; $show = $wpdb->hide_errors(); if ( !$options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); $wpdb->show_errors($show); - foreach ( $options as $option ) { + foreach ( (array) $options as $option ) { // "When trying to design a foolproof system, // never underestimate the ingenuity of the fools :)" -- Dougal if ( in_array( $option->option_name, array( 'siteurl', 'home', 'category_base', 'tag_base' ) ) ) @@ -441,8 +441,8 @@ function wp_load_alloptions() { } $suppress = $wpdb->suppress_errors(); - if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) - $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); + // order by option_id asc in case there are duplicate values - this makes the most recent value overwrite the others in the array + $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options FORCE INDEX(PRIMARY) ORDER BY option_id ASC" ); $wpdb->suppress_errors($suppress); foreach ( (array) $alloptions_db as $o ) $_wp_alloptions[$blog_id][$o->option_name] = $o->option_value; -- cgit