Clear post_meta cache upon change. Props nbachiyski. fixes #5718
git-svn-id: https://develop.svn.wordpress.org/trunk@6654 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4179e52a2b
commit
3b55c522d6
|
@ -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 ) ) )
|
||||
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);
|
||||
|
||||
$wpdb->insert( $wpdb->postmeta, compact( 'post_id', 'meta_key', 'meta_value' ) );
|
||||
|
||||
wp_delete_cache($post_id, 'post_meta');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue