Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#25545 closed defect (bug) (fixed)

Invalidate post cache when a user is removed from a blog

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

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 13 years ago.
invalidate_post_cache.patch​ (923 bytes ) - added by nprasath002 13 years ago.
25545.diff​ (752 bytes ) - added by wonderboymusic 13 years ago.
25545.2.diff​ (1.6 KB ) - added by wonderboymusic 13 years ago.
25545.3.diff​ (1.4 KB ) - added by kovshenin 13 years ago.
25545.4.diff​ (1.0 KB ) - added by kovshenin 13 years ago.

Download all attachments as: .zip

Change History (17)

#1 @nprasath002
13 years ago

  • Cc n.prasath.002@… added

#2 @wonderboymusic
13 years ago

  • Milestone Awaiting Review → 3.9

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

#3 @wonderboymusic
13 years ago

.2.diff adds a unit test.

#4 @wonderboymusic
13 years ago

  • Owner set to wonderboymusic
  • Resolution → fixed
  • Status new → 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
13 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
13 years ago

#6 @kovshenin
13 years ago

  • Resolution fixed
  • Status closed → reopened
  • Version 3.6.1 → 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
13 years ago

  • Resolution → fixed
  • Status reopened → 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
13 years ago

#8 @kovshenin
13 years ago

  • Resolution fixed
  • Status closed → 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
13 years ago

  • Resolution → fixed
  • Status reopened → 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
13 years ago

  • Resolution fixed
  • Status closed → reopened

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

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

#11 @nacin
13 years ago

  • Resolution → fixed
  • Status reopened → closed

In 27834:

Use correct column name. See [27152].

props barry.
fixes #25545.

Note: See TracTickets for help on using tickets.