Bump 'posts' query cache incrementor when modifying postmeta.

This ensures that the `get_pages()` query cache doesn't go stale when
postmeta is modified.

Props spacedmonkey.
Fixes #40669.
Built from https://develop.svn.wordpress.org/trunk@41849


git-svn-id: http://core.svn.wordpress.org/trunk@41683 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2017-10-12 15:20:47 +00:00
parent 0fce77da25
commit a1879766ed
2 changed files with 21 additions and 5 deletions

View File

@ -1728,7 +1728,11 @@ function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
if ( $the_post = wp_is_post_revision($post_id) )
$post_id = $the_post;
return add_metadata('post', $post_id, $meta_key, $meta_value, $unique);
$added = add_metadata( 'post', $post_id, $meta_key, $meta_value, $unique );
if ( $added ) {
wp_cache_set( 'last_changed', microtime(), 'posts' );
}
return $added;
}
/**
@ -1751,7 +1755,11 @@ function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) {
if ( $the_post = wp_is_post_revision($post_id) )
$post_id = $the_post;
return delete_metadata('post', $post_id, $meta_key, $meta_value);
$deleted = delete_metadata( 'post', $post_id, $meta_key, $meta_value );
if ( $deleted ) {
wp_cache_set( 'last_changed', microtime(), 'posts' );
}
return $deleted;
}
/**
@ -1793,7 +1801,11 @@ function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' )
if ( $the_post = wp_is_post_revision($post_id) )
$post_id = $the_post;
return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value);
$updated = update_metadata( 'post', $post_id, $meta_key, $meta_value, $prev_value );
if ( $updated ) {
wp_cache_set( 'last_changed', microtime(), 'posts' );
}
return $updated;
}
/**
@ -1805,7 +1817,11 @@ function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' )
* @return bool Whether the post meta key was deleted from the database.
*/
function delete_post_meta_by_key( $post_meta_key ) {
return delete_metadata( 'post', null, $post_meta_key, '', true );
$deleted = delete_metadata( 'post', null, $post_meta_key, '', true );
if ( $deleted ) {
wp_cache_set( 'last_changed', microtime(), 'posts' );
}
return $deleted;
}
/**

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-beta2-41848';
$wp_version = '4.9-beta2-41849';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.