Clear cache after deleting meta. Props Denis-de-Bernardy. fixes #9009
git-svn-id: https://develop.svn.wordpress.org/trunk@11305 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
58ab59ad76
commit
e2e4c53a93
@ -684,9 +684,11 @@ function delete_post_meta_by_key($post_meta_key) {
|
||||
return false;
|
||||
|
||||
global $wpdb;
|
||||
if ( $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key)) ) {
|
||||
/** @todo Get post_ids and delete cache */
|
||||
// wp_cache_delete($post_id, 'post_meta');
|
||||
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key));
|
||||
if ( $post_ids ) {
|
||||
$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key));
|
||||
foreach ( $post_ids as $post_id )
|
||||
wp_cache_delete($post_id, 'post_meta');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user