Make WordPress Core


Ignore:
Timestamp:
10/15/2012 05:51:38 AM (13 years ago)
Author:
markjaquith
Message:

Defer the meta_id-fetching query until after comparison of the previous value, so that redundant calls to update_metadata() can bail without making that query. props nacin. fixes #22191

File:
1 edited

Legend:

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

    r22103 r22231  
    124124        return (bool) $check;
    125125
    126     if ( ! $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ) )
    127         return add_metadata($meta_type, $object_id, $meta_key, $passed_value);
    128 
    129126    // Compare existing value to new value if no prev value given and the key exists only once.
    130127    if ( empty($prev_value) ) {
     
    135132        }
    136133    }
     134
     135    if ( ! $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ) )
     136        return add_metadata($meta_type, $object_id, $meta_key, $passed_value);
    137137
    138138    $_meta_value = $meta_value;
Note: See TracChangeset for help on using the changeset viewer.