diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 0ee3f2856c..692d591d7f 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -3918,7 +3918,7 @@ function wp_comments_personal_data_eraser( $email_address, $page = 1 ) { * @since 5.0.0 */ function wp_cache_set_comments_last_changed() { - wp_cache_set( 'last_changed', microtime(), 'comment' ); + wp_cache_set_last_changed( 'comment' ); } /** diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 37540ff571..1860598865 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -7680,12 +7680,42 @@ function wp_unique_id( $prefix = '' ) { function wp_cache_get_last_changed( $group ) { $last_changed = wp_cache_get( 'last_changed', $group ); - if ( ! $last_changed ) { - $last_changed = microtime(); - wp_cache_set( 'last_changed', $last_changed, $group ); + if ( $last_changed ) { + return $last_changed; } - return $last_changed; + return wp_cache_set_last_changed( $group ); +} + +/** + * Sets last changed date for the specified cache group to now. + * + * @since 6.3.0 + * + * @param string $group Where the cache contents are grouped. + * @return string UNIX timestamp when the group was last changed. + */ +function wp_cache_set_last_changed( $group ) { + $previous_time = wp_cache_get( 'last_changed', $group ); + + $time = microtime(); + + wp_cache_set( 'last_changed', $time, $group ); + + /** + * Fires after a cache group `last_changed` time is updated. + * This may occur multiple times per page load and registered + * actions must be performant. + * + * @since 6.3.0 + * + * @param string $group The cache group name. + * @param int $time The new last changed time. + * @param int|false $previous_time The previous last changed time. False if not previously set. + */ + do_action( 'wp_cache_set_last_changed', $group, $time, $previous_time ); + + return $time; } /** diff --git a/wp-includes/ms-network.php b/wp-includes/ms-network.php index 5d14d69ec7..8ab8819e26 100644 --- a/wp-includes/ms-network.php +++ b/wp-includes/ms-network.php @@ -96,7 +96,7 @@ function clean_network_cache( $ids ) { do_action( 'clean_network_cache', $id ); } - wp_cache_set( 'last_changed', microtime(), 'networks' ); + wp_cache_set_last_changed( 'networks' ); } /** diff --git a/wp-includes/ms-site.php b/wp-includes/ms-site.php index dca6a894cc..90cf484049 100644 --- a/wp-includes/ms-site.php +++ b/wp-includes/ms-site.php @@ -1281,7 +1281,7 @@ function wp_update_blog_public_option_on_site_update( $site_id, $is_public ) { * @since 5.1.0 */ function wp_cache_set_sites_last_changed() { - wp_cache_set( 'last_changed', microtime(), 'sites' ); + wp_cache_set_last_changed( 'sites' ); } /** diff --git a/wp-includes/post.php b/wp-includes/post.php index 112ba52b7b..876a1f7d0d 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -7805,7 +7805,7 @@ function wp_add_trashed_suffix_to_post_name_for_post( $post ) { * @since 5.0.0 */ function wp_cache_set_posts_last_changed() { - wp_cache_set( 'last_changed', microtime(), 'posts' ); + wp_cache_set_last_changed( 'posts' ); } /** diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index e0659af2b0..0832bffbe8 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -5038,7 +5038,7 @@ function is_term_publicly_viewable( $term ) { * @since 5.0.0 */ function wp_cache_set_terms_last_changed() { - wp_cache_set( 'last_changed', microtime(), 'terms' ); + wp_cache_set_last_changed( 'terms' ); } /** diff --git a/wp-includes/user.php b/wp-includes/user.php index 7495004d25..02f30dd36b 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -5024,5 +5024,5 @@ function wp_register_persisted_preferences_meta() { * @since 6.3.0 */ function wp_cache_set_users_last_changed() { - wp_cache_set( 'last_changed', microtime(), 'users' ); + wp_cache_set_last_changed( 'users' ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 75015bfef9..bcdbdcad2b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-55701'; +$wp_version = '6.3-alpha-55702'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.