Opened 10 years ago

Closed 10 years ago

#23661 closed Uncategorized (needsinfo)

Site cache doesn't cache in a per-database basis

Reported by: German M. Bravo Owned by: nobody
Component: contrib.sites Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The cache for Site (SITE_CACHE) should cache site objects for the database the object comes from. If there is a router in place and the current site is retrieved from one database, a second call for getting the current site from a different database will return the wrong object for that database.

Instead of using SITE_CACHE the way it's currently done, I propose using the same caching scheme as the one used in ContentType's _cache.

Attachments (1)

#23661-sites_cache_using.diff (2.6 KB ) - added by German M. Bravo 10 years ago.

Download all attachments as: .zip

Change History (3)

by German M. Bravo, 10 years ago

comment:1 by Tim Graham, 10 years ago

Component: Uncategorizedcontrib.sites

I'm not sure I understand the problem completely. Are you saying that in database A you could have (site_id=1, domain=example.com) and in database B (site_id=1, domain=example2.com)? Could you expand a bit on the use case and how you ran into this?

comment:2 by Tim Graham, 10 years ago

Resolution: needsinfo
Status: newclosed

As discussed in IRC, #15089 may solve the use case here (allowing lookup of the current site based on request.get_host()). If not, we need to decide whether we'd officially support this particular configuration of contrib.sites. While caching the site based on database seems valid, I'm opposed to adding complexity unless there's a valid use case.

Note: See TracTickets for help on using tickets.
Back to Top