Make WordPress Core

Opened 2 years ago

Closed 12 months ago

Last modified 12 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:

Description

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.


2 years ago
#1

  • Keywords has-patch added

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


14 months ago
#2

This is intended as a simple version of #1776

Trac ticket: https://core.trac.wordpress.org/ticket/54316

@dd32 commented on PR #1776:


14 months ago
#3

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

#4 @spacedmonkey
13 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:


13 months ago
#5

Closing in favour of #3447

@dd32 commented on PR #3447:


13 months ago
#6

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 https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/post.php#L7373

#7 @dd32
13 months ago

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

#8 @spacedmonkey
13 months ago

  • Keywords commit added

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

#9 @spacedmonkey
12 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:


12 months ago
#10

Committed

Note: See TracTickets for help on using tickets.