Changeset 2715

Show
Ignore:
Timestamp:
07/16/05 21:13:14 (3 years ago)
Author:
matt
Message:

Check it if matches before serializing, because get_option de-serializes. Hat tip: Donncha.

Files:

Legend:

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

    r2704 r2715  
    328328function update_option($option_name, $newvalue) { 
    329329    global $wpdb, $cache_settings; 
     330 
     331    $newvalue = trim($newvalue); // I can't think of any situation we wouldn't want to trim 
     332 
     333    // If the new and old values are the same, no need to update. 
     334    if ( $newvalue == get_option($option_name) ) 
     335        return true; 
     336 
    330337    if ( is_array($newvalue) || is_object($newvalue) ) 
    331338        $newvalue = serialize($newvalue); 
    332  
    333     $newvalue = trim($newvalue); // I can't think of any situation we wouldn't want to trim 
    334  
    335     // If the new and old values are the same, no need to update. 
    336     if ($newvalue == get_option($option_name)) { 
    337         return true; 
    338     } 
    339339 
    340340    // If it's not there add it 
     
    343343 
    344344    $newvalue = $wpdb->escape($newvalue); 
     345    $option_name = $wpdb->escape( $option_name ); 
    345346    $wpdb->query("UPDATE $wpdb->options SET option_value = '$newvalue' WHERE option_name = '$option_name'"); 
    346347    $cache_settings = get_alloptions(); // Re cache settings