Invalidate comment query cache when modifying comment meta.
Comment queries are sensitive to comment meta due to the `meta_query` parameter, so the cache must be invalidated when comment meta is changed, added, or deleted. Props spacedmonkey. See #40669. Built from https://develop.svn.wordpress.org/trunk@41848 git-svn-id: http://core.svn.wordpress.org/trunk@41682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3bfe1f6c21
commit
0fce77da25
|
@ -423,7 +423,11 @@ function get_comment_count( $post_id = 0 ) {
|
|||
* @return int|bool Meta ID on success, false on failure.
|
||||
*/
|
||||
function add_comment_meta($comment_id, $meta_key, $meta_value, $unique = false) {
|
||||
return add_metadata('comment', $comment_id, $meta_key, $meta_value, $unique);
|
||||
$added = add_metadata( 'comment', $comment_id, $meta_key, $meta_value, $unique );
|
||||
if ( $added ) {
|
||||
wp_cache_set( 'last_changed', microtime(), 'comment' );
|
||||
}
|
||||
return $added;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -442,7 +446,11 @@ function add_comment_meta($comment_id, $meta_key, $meta_value, $unique = false)
|
|||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
function delete_comment_meta($comment_id, $meta_key, $meta_value = '') {
|
||||
return delete_metadata('comment', $comment_id, $meta_key, $meta_value);
|
||||
$deleted = delete_metadata( 'comment', $comment_id, $meta_key, $meta_value );
|
||||
if ( $deleted ) {
|
||||
wp_cache_set( 'last_changed', microtime(), 'comment' );
|
||||
}
|
||||
return $deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -479,7 +487,11 @@ function get_comment_meta($comment_id, $key = '', $single = false) {
|
|||
* @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure.
|
||||
*/
|
||||
function update_comment_meta($comment_id, $meta_key, $meta_value, $prev_value = '') {
|
||||
return update_metadata('comment', $comment_id, $meta_key, $meta_value, $prev_value);
|
||||
$updated = update_metadata( 'comment', $comment_id, $meta_key, $meta_value, $prev_value );
|
||||
if ( $updated ) {
|
||||
wp_cache_set( 'last_changed', microtime(), 'comment' );
|
||||
}
|
||||
return $updated;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9-beta2-41847';
|
||||
$wp_version = '4.9-beta2-41848';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue