mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 23:41:38 +01:00
Clear post_meta cache upon change. Props nbachiyski. fixes #5718
git-svn-id: http://svn.automattic.com/wordpress/trunk@6654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3c0db5ec37
commit
e5c94063b0
@ -485,17 +485,12 @@ function add_post_meta($post_id, $meta_key, $meta_value, $unique = false) {
|
|||||||
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 ) ) )
|
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 ) ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$cache = wp_cache_get($post_id, 'post_meta');
|
|
||||||
if ( ! is_array($cache) )
|
|
||||||
$cache = array();
|
|
||||||
// expected_slashed ($meta_key)
|
|
||||||
$cache[$wpdb->escape($meta_key)][] = $meta_value;
|
|
||||||
|
|
||||||
wp_cache_set($post_id, $cache, 'post_meta');
|
|
||||||
|
|
||||||
$meta_value = maybe_serialize($meta_value);
|
$meta_value = maybe_serialize($meta_value);
|
||||||
|
|
||||||
$wpdb->insert( $wpdb->postmeta, compact( 'post_id', 'meta_key', 'meta_value' ) );
|
$wpdb->insert( $wpdb->postmeta, compact( 'post_id', 'meta_key', 'meta_value' ) );
|
||||||
|
|
||||||
|
wp_delete_cache($post_id, 'post_meta');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user