Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#40247 closed defect (bug) (fixed)

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

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

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 10 years ago.

Download all attachments as: .zip

Change History (4)

#1 @flixos90
10 years ago

  • Keywords has-patch has-unit-tests added; needs-patch removed
  • Milestone Awaiting Review → 4.8

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

#2 @jeremyfelt
10 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
10 years ago

  • Owner set to jeremyfelt
  • Resolution → fixed
  • Status new → 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.