Users: Clear the user_meta cache when clean_user_cache function is called.

Unlike other clean cache functions like `clean_post_cache`, `clean_user_cache` did not also clear user meta caches. This is inconsistent and can result in some strange side effects. Update the `clean_user_cache` function to also clear user meta caches when called. 

Props dd32, spacedmonkey, peterwilsoncc.
Fixes #54316.

git-svn-id: https://develop.svn.wordpress.org/trunk@54940 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
spacedmonkey
2022-12-06 13:52:02 +00:00
parent 7a9ffd079d
commit 08dfd2b550
2 changed files with 82 additions and 0 deletions

View File

@@ -1873,6 +1873,7 @@ function update_user_caches( $user ) {
*
* @since 3.0.0
* @since 4.4.0 'clean_user_cache' action was added.
* @since 6.2.0 User metadata caches are now cleared.
*
* @param WP_User|int $user User object or ID to be cleaned from the cache
*/
@@ -1893,6 +1894,8 @@ function clean_user_cache( $user ) {
wp_cache_delete( $user->user_email, 'useremail' );
}
wp_cache_delete( $user->ID, 'user_meta' );
/**
* Fires immediately after the given user's cache is cleaned.
*