WordPress.org

Make WordPress Core

Ticket #11627: meta.no-function.diff

File meta.no-function.diff, 1.6 KB (added by wnorris, 4 years ago)
  • meta.php

     
    5353        global $wpdb; 
    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 
    6364        $meta_value = maybe_serialize( stripslashes_deep($meta_value) ); 
     
    9091        global $wpdb; 
    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 ) 
    100102                $query .= $wpdb->prepare(" AND $type_column = %d", $object_id ); 
     
    106108        if ( !count( $meta_ids ) ) 
    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); 
    112114