Changeset 1490

Show
Ignore:
Timestamp:
09/22/08 11:25:04 (2 months ago)
Author:
donncha
Message:

Add default value back into get_option()
Get all options to store in cache, thanks Will Norris, props Tellyworth

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/functions.php

    r1413 r1490  
    320320 * @return mixed Value set for the option. 
    321321 */ 
    322 function get_option( $setting ) { 
     322function get_option( $setting, $default = false ) { 
    323323        global $wpdb, $switched, $current_blog; 
    324324 
     
    331331        $value = _get_option_cache( $setting ); 
    332332        if ( false === $value ) 
    333                         return false
     333                        return $default
    334334 
    335335        // If home is not set use siteurl. 
     
    393393 */ 
    394394function get_alloptions() { 
    395         global $wpdb, $wp_queries
     395        global $wpdb
    396396        $show = $wpdb->hide_errors(); 
    397397        if ( !$options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) 
     
    399399        $wpdb->show_errors($show); 
    400400 
    401         foreach ( $options as $option ) { 
     401        foreach ( (array) $options as $option ) { 
    402402                // "When trying to design a foolproof system, 
    403403                //  never underestimate the ingenuity of the fools :)" -- Dougal 
     
    442442 
    443443        $suppress = $wpdb->suppress_errors(); 
    444         if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) 
    445                $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); 
     444        // order by option_id asc in case there are duplicate values - this makes the most recent value overwrite the others in the array 
     445        $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options FORCE INDEX(PRIMARY) ORDER BY option_id ASC" ); 
    446446        $wpdb->suppress_errors($suppress); 
    447447        foreach ( (array) $alloptions_db as $o )