Make WordPress Core

Opened 20 months ago

Closed 6 months ago

Last modified 6 months ago

#54316 closed defect (bug) (fixed)

clean_user_cache() doesn't clear the user_meta cache

Reported by: dd32's profile dd32 Owned by: spacedmonkey's profile spacedmonkey
Milestone: 6.2 Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch has-unit-tests commit
Focuses: Cc:


Calling clean_user_cache() doesn't clear the user_meta cache, which can cause odd behaviours when the reason for calling it is that the user or usermeta DB tables have been altered.

Additionally, there is no API for clearing the metadata caches, other than performing a direct wp_cache_delete( $id, 'user_meta' );.

See attached PR.

Change History (10)

This ticket was mentioned in PR #1776 on WordPress/wordpress-develop by dd32.

20 months ago

  • Keywords has-patch added

This ticket was mentioned in PR #3447 on WordPress/wordpress-develop by @dd32.

8 months ago

This is intended as a simple version of #1776

Trac ticket:

@dd32 commented on PR #1776:

8 months ago

I've refreshed this against trunk, but also opened #3447 which is a simpler straight to the point fix.

#4 @spacedmonkey
7 months ago

  • Milestone changed from Awaiting Review to 6.2
  • Owner set to spacedmonkey
  • Status changed from new to assigned

@dd32 commented on PR #1776:

7 months ago

Closing in favour of #3447

@dd32 commented on PR #3447:

7 months ago

Just noting that I've force-pushed this around a little to run a unit test that fails (for users, passes for posts) first, and then the original commit on top of that showing the unit test passing.

Posts passed originally as clean_post_cache() calls the same wp_cache_delete(), see

#7 @dd32
7 months ago

  • Keywords has-unit-tests added; needs-unit-tests removed

#8 @spacedmonkey
7 months ago

  • Keywords commit added

This looks good to go to me. Adding commit keyword.

#9 @spacedmonkey
6 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 54940:

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.

@spacedmonkey commented on PR #3447:

6 months ago


Note: See TracTickets for help on using tickets.