Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#40247 closed defect (bug) (fixed)

Fix the `site-details` cache not being set sometimes

Reported by: flixos90's profile flixos90 Owned by: jeremyfelt's profile jeremyfelt
Milestone: 4.8 Priority: normal
Severity: normal Version: 4.6
Component: Networks and Sites Keywords: has-patch has-unit-tests
Focuses: multisite Cc:

Description

When introducing the lazy-loading functionality for sites in 37918, we made a mistake as far as I can see: In WP_Site::get_details() we check for falsy site detail values, and if one of them is false, the data is not cached. This is a problem, since sometimes that data can actually be not set (mainly post_count).

When reading through the original ticket #36935, the reason we implemented this check was so that the function wouldn't cache an invalid dataset when requesting site details too early (for example in sunrise.php). However, a little further in that discussion we decided that we'd introduce the ms_loaded hook and use that for detection instead. That's what we ended up doing, but never removed the original checks, which should under those new circumstances be unnecessary, and actually cause this problem.

Attachments (1)

40247.diff (1.5 KB) - added by flixos90 7 years ago.

Download all attachments as: .zip

Change History (4)

@flixos90
7 years ago

#1 @flixos90
7 years ago

  • Keywords has-patch has-unit-tests added; needs-patch removed
  • Milestone changed from Awaiting Review to 4.8

40247.diff fixes the bug and introduces a new unit test for the issue.

#2 @jeremyfelt
7 years ago

@flixos90 Looks good! I had an issue running tests with an object cache enabled locally, and tracked that down to [40343]. Once that was fixed, things work as expected in all test configurations.

#3 @jeremyfelt
7 years ago

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

In 40344:

Multisite: Allow falsy properties to be cached in site-details.

In previous iterations of WP_Site, there was concern that not all properties would be available when storing a site's details in cache. When introduced in [37918], an ms_loaded check was added to address this concern. Any properties that are still false after ms_loaded really are false and can be cached as such.

Props flixos90.
Fixes #40247.

Note: See TracTickets for help on using tickets.