revolution icon indicating copy to clipboard operation
revolution copied to clipboard

Fix issues with extending modSessionHandler and flushing all sessions

Open Mark-H opened this issue 2 years ago • 1 comments

What does it do?

  • Fixes the bugs from #15928, per #15934
  • Refactored inititialization of the session handler and adopt the PHP core SessionHandlerInterface, per #15934
  • Move flushing sessions logic into the session handler to optionally allow that to be extended, per #15957

Why is it needed?

In two stale PRs #15928 and #15957 we have two proposals for dealing with some bugs and extending session handlers. While trying to figure out which one to use, I found both to have a solid approach, and wanting to use one bit of one and another part of other PR.

This proposal replaces both those PRs as a middle ground, taking the most benefit from both approachs.

Breaking changes

This change includes a small breaking change in order to adopt the PHP standard SessionHandlerInterface, namely adding parameters into the open() method. There's not really any way around that in order to adopt the standard.

As extending session handlers is a pretty advanced thing that I assume not many people have done, I suggest we accept that for the sake of getting closer to the standards, but make special note of this breaking change in the docs for 3.1 and the announcement to make sure people learn about it in case custom handlers need to be adjusted.

How to test

Flush sessions

Related issue(s)/PR(s)

Replaces #15934 and #15957 Fixes #15928

Mark-H avatar Feb 10 '24 12:02 Mark-H

Codecov Report

Attention: Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.

Project coverage is 21.68%. Comparing base (73bfd27) to head (ac621d1). Report is 146 commits behind head on 3.x.

Files Patch % Lines
core/src/Revolution/Processors/Security/Flush.php 0.00% 8 Missing :warning:
core/src/Revolution/modSessionHandler.php 0.00% 8 Missing :warning:
core/src/Revolution/modX.php 0.00% 7 Missing :warning:
Additional details and impacted files
@@            Coverage Diff            @@
##                3.x   #16522   +/-   ##
=========================================
  Coverage     21.68%   21.68%           
  Complexity    10496    10496           
=========================================
  Files           561      561           
  Lines         31703    31699    -4     
=========================================
  Hits           6875     6875           
+ Misses        24828    24824    -4     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 10 '24 12:02 codecov[bot]