WordPress.org

Make WordPress Core

Opened 21 months ago

Closed 20 months ago

Last modified 20 months 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 21 months ago.
21595.diff (1.6 KB) - added by ryan 20 months ago.
21595-ut.diff (2.5 KB) - added by ryan 20 months ago.
21595.2.diff (1.9 KB) - added by ryan 20 months ago.

Download all attachments as: .zip

Change History (13)

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

jondavidjohn21 months ago

comment:2 jondavidjohn21 months ago

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

ryan20 months ago

comment:3 follow-up: ryan20 months 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.

ryan20 months ago

comment:4 in reply to: ↑ 3 nacin20 months 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.

ryan20 months ago

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

comment:7 ryan20 months 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

comment:9 nacin20 months ago

#19420 was marked as a duplicate.

Note: See TracTickets for help on using tickets.