Make WordPress Core


Ignore:
Timestamp:
05/12/2009 05:10:05 PM (15 years ago)
Author:
ryan
Message:

Clear cache after deleting meta. Props Denis-de-Bernardy. fixes #9009

File:
1 edited

Legend:

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

    r11284 r11305  
    685685
    686686    global $wpdb;
    687     if ( $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key)) ) {
    688         /** @todo Get post_ids and delete cache */
    689         // wp_cache_delete($post_id, 'post_meta');
     687    $post_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key));
     688    if ( $post_ids ) {
     689        $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key));
     690        foreach ( $post_ids as $post_id )
     691            wp_cache_delete($post_id, 'post_meta');
    690692        return true;
    691693    }
Note: See TracChangeset for help on using the changeset viewer.