Ticket #5718: add_post_meta-cache-corruption.diff

File add_post_meta-cache-corruption.diff, 803 bytes (added by nbachiyski, 4 years ago)
  • wp-includes/post.php

     
    485485        if ( $unique && $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->postmeta WHERE meta_key = %s AND post_id = %d", $meta_key, $post_id ) ) ) 
    486486                return false; 
    487487 
    488         $cache = wp_cache_get($post_id, 'post_meta'); 
    489         if ( ! is_array($cache) ) 
    490                 $cache = array(); 
    491         // expected_slashed ($meta_key) 
    492         $cache[$wpdb->escape($meta_key)][] = $meta_value; 
    493  
    494         wp_cache_set($post_id, $cache, 'post_meta'); 
    495  
    496488        $meta_value = maybe_serialize($meta_value); 
    497489 
    498490        $wpdb->insert( $wpdb->postmeta, compact( 'post_id', 'meta_key', 'meta_value' ) ); 
     491 
     492        wp_delete_cache($post_id, 'post_meta'); 
     493 
    499494        return true; 
    500495} 
    501496