Opened 6 years ago

Last modified 2 years ago

#12794 new Bug

Interaction between sessions and django.views.i18n.set_language causes caching errors

Reported by: alessandro.gudio+bugzilla@… Owned by: nobody
Component: Internationalization Version: 1.1
Severity: Normal Keywords: cache i18n
Cc: alessandro.guido+bugzilla@…, raymond.penners@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

The django.views.i18n.set_language view uses the session to store the language if it is available.
If a user has a session and tries to change the language, this change is reflected only in the variables inside the session storage. Since the headers of following requests won't change, the caching framework cannot detect such change and cached pages in the previous language will be returned.

I suggest always using cookies to store language.

Attachments (1)

cooki18n.patch (3.0 KB) - added by pennersr 4 years ago.
No longer store language in session

Download all attachments as: .zip

Change History (12)

comment:1 Changed 6 years ago by anonymous

  • Cc alessandro.guido+bugzilla@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 years ago by russellm

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 4 years ago by lukeplant

  • Type set to Bug

comment:4 Changed 4 years ago by lukeplant

  • Severity set to Normal

comment:5 Changed 4 years ago by lukeplant

  • Easy pickings unset

See also #15902

comment:6 Changed 4 years ago by raymond.penners@…

  • Cc raymond.penners@… added

comment:7 Changed 4 years ago by raymond.penners@…

For those interested, you can use the following Django app to have the language stored in a cookie as suggested.

https://github.com/pennersr/django-cooki18n

Changed 4 years ago by pennersr

No longer store language in session

comment:8 Changed 4 years ago by pennersr

  • Has patch set
  • UI/UX unset

I have attached a patch that stops Django from storing the language in the session.

A decision is needed on whether support for storing the language in the session is to be completely dropped, or whether it is to be made configurable via settings. For now, the old behaviour has been put below an "if False:" so that it can be easily reinstantiated.

comment:9 Changed 4 years ago by ramiro

#16461 was a duplicate, reported similar problems but with browsers caches.

comment:10 Changed 3 years ago by jezdez

  • Needs documentation set
  • Patch needs improvement set
Note: See TracTickets for help on using tickets.
Back to Top