WordPress.org

Make WordPress Core

Changeset 17078


Ignore:
Timestamp:
12/20/2010 12:38:21 PM (7 years ago)
Author:
ryan
Message:

Restrict meta update/delete to the current post. Props kawauso. fixes #15276

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/post.php

    r17071 r17078  
    193193    // Meta Stuff
    194194    if ( isset($post_data['meta']) && $post_data['meta'] ) {
    195         foreach ( $post_data['meta'] as $key => $value )
     195        foreach ( $post_data['meta'] as $key => $value ) {
     196            if ( !$meta = get_post_meta_by_id( $key ) )
     197                continue;
     198            if ( $meta->post_id != $post_ID )
     199                continue;
    196200            update_meta( $key, $value['key'], $value['value'] );
     201        }
    197202    }
    198203
    199204    if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) {
    200         foreach ( $post_data['deletemeta'] as $key => $value )
     205        foreach ( $post_data['deletemeta'] as $key => $value ) {
     206            if ( !$meta = get_post_meta_by_id( $key ) )
     207                continue;
     208            if ( $meta->post_id != $post_ID )
     209                continue;
    201210            delete_meta( $key );
     211        }
    202212    }
    203213
Note: See TracChangeset for help on using the changeset viewer.