WordPress.org

Make WordPress Core

Changeset 16017


Ignore:
Timestamp:
10/27/2010 05:45:08 PM (9 years ago)
Author:
scribu
Message:

Fix inconsistencies in metadata filters. Props sc0ttkclark. See #14766

File:
1 edited

Legend:

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

    r15983 r16017  
    4545    // expected_slashed ($meta_key)
    4646    $meta_key = stripslashes($meta_key);
     47    $meta_value = stripslashes_deep($meta_value);
    4748
    4849    $check = apply_filters( "add_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $unique );
     
    5657
    5758    $_meta_value = $meta_value;
    58     $meta_value = maybe_serialize( stripslashes_deep($meta_value) );
     59    $meta_value = maybe_serialize( $meta_value );
    5960
    6061    do_action( "add_{$meta_type}_meta", $object_id, $meta_key, $_meta_value );
     
    112113    // expected_slashed ($meta_key)
    113114    $meta_key = stripslashes($meta_key);
     115    $meta_value = stripslashes_deep($meta_value);
    114116
    115117    $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
     
    130132
    131133    $_meta_value = $meta_value;
    132     $meta_value = maybe_serialize( stripslashes_deep($meta_value) );
     134    $meta_value = maybe_serialize( $meta_value );
    133135
    134136    $data  = compact( 'meta_value' );
     
    187189    // expected_slashed ($meta_key)
    188190    $meta_key = stripslashes($meta_key);
    189     $meta_value = maybe_serialize( stripslashes_deep($meta_value) );
     191    $meta_value = stripslashes_deep($meta_value);
    190192
    191193    $check = apply_filters( "delete_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $delete_all );
     
    193195        return (bool) $check;
    194196
     197    $_meta_value = $meta_value;
     198    $meta_value = maybe_serialize( $meta_value );
     199
    195200    $query = $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s", $meta_key );
    196201
     
    205210        return false;
    206211
    207     do_action( "delete_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $meta_value );
     212    do_action( "delete_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
    208213
    209214    $query = "DELETE FROM $table WHERE $id_column IN( " . implode( ',', $meta_ids ) . " )";
     
    219224        clean_user_cache($object_id);
    220225
    221     do_action( "deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $meta_value );
     226    do_action( "deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
    222227
    223228    return true;
     
    246251    $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single );
    247252    if ( null !== $check ) {
    248         if ( !is_array( $check ) )
     253        if ( $single && is_array( $check ) )
     254            return $check[0];
     255        else
    249256            return $check;
    250         elseif ( $single )
    251             return maybe_unserialize( $check[0] );
    252         else
    253             return array_map( 'maybe_unserialize', $check );
    254257    }
    255258
Note: See TracChangeset for help on using the changeset viewer.