Code

Opened 18 months ago

Closed 18 months ago

Last modified 18 months ago

#19254 closed Bug (fixed)

clear_expired for Sessions With File Backend Throws Exception

Reported by: simonb Owned by: nobody
Component: contrib.sessions Version: 1.5-alpha-1
Severity: Release blocker Keywords: sessions filebackend
Cc: bnomis@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The following line in clear_expired for file based sessions does not do what the author intended:

storage_path = getattr(settings, "SESSION_FILE_PATH", tempfile.gettempdir())

tempfile.gettempdir() will only be called if SESSION_FILE_PATH does not exist in settings. But it does exist and defaults to None. The exception occurs in the call os.listdir(storage_path).

What is probably required is this:

storage_path = getattr(settings, "SESSION_FILE_PATH", None)
if not storage_path:
    storage_path = tempfile.gettempdir()

or this:

storage_path = cls._get_storage_path()

Attachments (0)

Change History (5)

comment:1 Changed 18 months ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 18 months ago by simonb

  • Cc bnomis@… added

comment:3 Changed 18 months ago by aaugustin

Good catch — that's why I factored out _get_storage_path! And I forgot to use it in the final patch :(

This mistake wasn't caught because Django forces the value of SESSION_FILE_PATH in order to be able to clean up after the tests.

comment:4 Changed 18 months ago by Aymeric Augustin <aymeric.augustin@…>

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

In 93e0ec553dae73a2a86cb23b058414d8f9ae3bd6:

[1.5.x] Fixed #19254 -- Bug in SESSION_FILE_PATH handling.

Thanks simonb for the report.

Refs #18194.

Backport of 11fd00c from master.

comment:5 Changed 18 months ago by Aymeric Augustin <aymeric.augustin@…>

In 11fd00c46e2826ce5852e096487762a96909b717:

Fixed #19254 -- Bug in SESSION_FILE_PATH handling.

Thanks simonb for the report.

Refs #18194.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.