Issue #3634400: Use a finally block to save the session when the inner kernel throws

Closes #3634400

Does 3 things:

  • In StackMiddleware/Session.php a try/finally now wraps the httpKernel call. The finally will save the session if the kernel throws, which was not happening before and would leave the session open. That would lead to lost session data and caused a fatal error in `SessionHandler::doWrite()`.
  • As requested by comment #10 the Session middleware docblock now mentions that mutating the session after it has been saved is not supported.
  • Adds a test that fails without this fix.

Generated with the help of an LLM.

Merge request reports

Loading
Loading