Make WordPress Core

Changeset 14564


Ignore:
Timestamp:
05/11/2010 05:35:07 PM (16 years ago)
Author:
ryan
Message:

Don't update meta data when the new value matches the old value. fixes #13350

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/meta.php

    r14547 r14564  
    109109        if ( ! $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ) )
    110110                return add_metadata($meta_type, $object_id, $meta_key, $meta_value);
     111
     112        // Compare existing value to new value if no prev value given and the key exists only once.
     113        if ( empty($prev_value) ) {
     114                $old_value = get_metadata($meta_type, $object_id, $meta_key);
     115                if ( count($old_value) == 1 ) {
     116                        if ( $old_value[0] == $meta_value )
     117                                return false;
     118                }
     119        }
    111120
    112121        $_meta_value = $meta_value;
Note: See TracChangeset for help on using the changeset viewer.