WordPress.org

Make WordPress Core

Opened 6 months ago

Closed 3 weeks 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:

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

Download all attachments as: .zip

Change History (17)

comment:1 nprasath0026 months ago

  • Cc n.prasath.002@… added

wonderboymusic3 months ago

comment:2 wonderboymusic3 months ago

  • Milestone changed from Awaiting Review to 3.9

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

wonderboymusic2 months ago

comment:3 wonderboymusic2 months ago

.2.diff adds a unit test.

comment:4 wonderboymusic2 months 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.

comment:5 TobiasBg2 months 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?

kovshenin2 months ago

comment:6 kovshenin2 months 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.

comment:7 wonderboymusic2 months 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.

kovshenin2 months ago

comment:8 kovshenin2 months 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.

comment:9 wonderboymusic2 months 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.)

comment:10 barry3 weeks 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 3 weeks ago by barry (previous) (diff)

comment:11 nacin3 weeks 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.