WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#21595 closed defect (bug) (fixed)

get_blog_post() and get_blog_permalink() create duplicate caches that aren't invalidated

Reported by: ryan Owned by: ryan
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.4.1
Component: Cache API Keywords: has-patch needs-testing
Focuses: Cc:

Description

Both of these copy per blog information to global caches and never invalidate that information when the sources change.

Attachments (4)

ms-functions.diff (734 bytes) - added by jondavidjohn 7 years ago.
21595.diff (1.6 KB) - added by ryan 7 years ago.
21595-ut.diff (2.5 KB) - added by ryan 7 years ago.
21595.2.diff (1.9 KB) - added by ryan 7 years ago.

Download all attachments as: .zip

Change History (13)

#1 @nacin
7 years ago

get_blog_post() should also use switch_to_blog() like get_blog_permalink().

Persistent caching that we get via switch_to_blog() should be enough, no? The double-caching seems weird.

#2 @jondavidjohn
7 years ago

  • Cc me@… added
  • Keywords has-patch needs-testing added

@ryan
7 years ago

#3 follow-up: @ryan
7 years ago

Actually, global-posts is invalidated at the end of clean_post_cache() so get_blog_post() isn't as bad as it first seemed.

@ryan
7 years ago

#4 in reply to: ↑ 3 @nacin
7 years ago

Replying to ryan:

Actually, global-posts is invalidated at the end of clean_post_cache() so get_blog_post() isn't as bad as it first seemed.

We can kill that line now, though. 21595.diff looks good.

@ryan
7 years ago

#5 @ryan
7 years ago

That removes the invalidation. Those rare third parties who might be relying on that invalidation would have to perform the invalidation themselves on a clean_post_cache hook. I left the registration of global-posts as a global group in for now.

#7 @ryan
7 years ago

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

In [21628]:

Use switch_to_blog()/restore_current_blog() in get_blog_post() and get_blog_permalink(). Eliminate the duplicate caching in these functions. Return WP_Post from get_blog_post(). Update phpdoc. Remove global-posts cache invalidation. Props jondavidjohn fixes #21595

#9 @nacin
7 years ago

#19420 was marked as a duplicate.

Note: See TracTickets for help on using tickets.