WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#25545 closed defect (bug) (fixed)

Invalidate post cache when a user is removed from a blog

Reported by: nprasath002 Owned by: wonderboymusic
Milestone: 3.9 Priority: normal
Severity: minor Version: 3.0
Component: Cache API Keywords: has-patch
Focuses: Cc:
PR Number:

Description

In remove_user_from_blog invalidate post cache when a user is removed from a blog

Attachments (6)

Invalidate_post_cache_when_a_user_is_removed.patch (859 bytes) - added by nprasath002 6 years ago.
invalidate_post_cache.patch (923 bytes) - added by nprasath002 6 years ago.
25545.diff (752 bytes) - added by wonderboymusic 6 years ago.
25545.2.diff (1.6 KB) - added by wonderboymusic 6 years ago.
25545.3.diff (1.4 KB) - added by kovshenin 6 years ago.
25545.4.diff (1.0 KB) - added by kovshenin 6 years ago.

Download all attachments as: .zip

Change History (17)

#1 @nprasath002
6 years ago

  • Cc n.prasath.002@… added

@wonderboymusic
6 years ago

#2 @wonderboymusic
6 years ago

  • Milestone changed from Awaiting Review to 3.9

Good catch, @nprasath002. I added a new patch here: 25545.diff

#3 @wonderboymusic
6 years ago

.2.diff adds a unit test.

#4 @wonderboymusic
6 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 27087:

Invalidate the post cache for posts associated with a user who has been removed from a blog in remove_user_from_blog(). Adds a unit test.

Props nprasath002 for the initial patch.
Fixes #25545.

#5 @TobiasBg
6 years ago

Would array_walk( $post_ids, 'clean_post_cache' ); be more appropriate here than array_map(...), to make it clearer that we don't expect/need the return array?

@kovshenin
6 years ago

#6 @kovshenin
6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Version changed from 3.6.1 to 3.0

In r27087 you're invalidating caches for all the existing posts of the receiving user. We really just need the ones that belong(ed) to the user being removed. Also this seems like a no-brainer for links as well and since they're still in core, let's clean those caches too. See 25545.3.diff.

#7 @wonderboymusic
6 years ago

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

In 27152:

Collect the post and link ids that will be reassigned before running the update in remove_user_from_blog(). Use array_walk() instead of array_map() when invalidating the caches for the collected ids.

Props kovshenin.
Fixes #25545.

@kovshenin
6 years ago

#8 @kovshenin
6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Hi, sorry :) I'm having second thoughts about the INs in the queries in r27152, even though they're probably faster, they won't scale with large amounts of posts. Let's change those back. See 25545.4.diff.

#9 @wonderboymusic
6 years ago

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

In 27161:

In remove_user_from_blog(), avoid a potentially expensive IN query before invalidating the reassigned post and link caches.

Props kovshenin.
Fixes #25545. (Again.)

#10 @barry
6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

There is a typo in r27152. There is no ID field in the links table. The primary key is link_id

Last edited 6 years ago by barry (previous) (diff)

#11 @nacin
6 years ago

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

In 27834:

Use correct column name. See [27152].

props barry.
fixes #25545.

Note: See TracTickets for help on using tickets.