WordPress.org

Make WordPress Core

Opened 5 weeks ago

Last modified 2 weeks ago

#42251 new enhancement

Cache not found values for sites and network lookups by ID

Reported by: flixos90 Owned by:
Milestone: 5.0 Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: needs-unit-tests dev-feedback has-patch
Focuses: multisite Cc:

Description

Currently when running get_site( 12345 ) and no ID with that site exists, the result is not being cached. That means every subsequent lookup will still cause a DB query to be fired, which is unnecessary. The exact same applies to networks as well.

Let's make sure falsy lookups are still cached under the ID checked.

That also implies that upon creating a new site or network, its respective ID cache must be cleared to not longer receive the cached falsy result. This is already the case for sites anyway, for networks it's a bit more tricky because we don't have a real API for that. However, with a dev-note clarifying that, also given how "edge-case" multiple networks are, I think we're good making that change.

Attachments (1)

42251.diff (2.0 KB) - added by flixos90 5 weeks ago.

Download all attachments as: .zip

Change History (4)

@flixos90
5 weeks ago

#1 @flixos90
5 weeks ago

  • Keywords has-patch added; needs-patch removed

42251.diff caches the value -1 for falsy lookups of sites and networks by ID. It furthermore ensures that upon inserting a new network, the cache value for that ID is cleaned.

This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.


2 weeks ago

#3 @jeremyfelt
2 weeks ago

  • Milestone changed from Awaiting Review to 5.0
Note: See TracTickets for help on using tickets.