WordPress.org

Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.9/wp-includes/meta.php

    r12173 r12563  
    5454
    5555    $column = esc_sql($meta_type . '_id');
     56    $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
    5657
    5758    // expected_slashed ($meta_key)
    5859    $meta_key = stripslashes($meta_key);
    5960
    60     if ( ! $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ) )
     61    if ( ! $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ) )
    6162        return add_metadata($meta_type, $object_id, $meta_key, $meta_value);
    6263
     
    9192
    9293    $type_column = esc_sql($meta_type . '_id');
     94    $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
    9395    // expected_slashed ($meta_key)
    9496    $meta_key = stripslashes($meta_key);
    9597    $meta_value = maybe_serialize( stripslashes_deep($meta_value) );
    9698
    97     $query = $wpdb->prepare( "SELECT meta_id FROM $table WHERE meta_key = %s", $meta_key );
     99    $query = $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s", $meta_key );
    98100
    99101    if ( !$delete_all )
     
    107109        return false;
    108110
    109     $query = "DELETE FROM $table WHERE meta_id IN( " . implode( ',', $meta_ids ) . " )";
     111    $query = "DELETE FROM $table WHERE $id_column IN( " . implode( ',', $meta_ids ) . " )";
    110112
    111113    $count = $wpdb->query($query);
Note: See TracChangeset for help on using the changeset viewer.