Skip to content

[Issue] Fix silent fallback to file sessions when session/save is set to Valkey #41108

Description

@m2-assistant

This issue is automatically created based on existing pull request: #41099: Fix silent fallback to file sessions when session/save is set to Valkey


Description (*)

Magento\Framework\Session\SaveHandlerFactory registers only the db and redis session save handlers (app/etc/di.xml). However, bin/magento setup:config:set --session-save=valkey is a documented, supported command that writes session/save = valkey plus a session/valkey connection group to app/etc/env.php.

Because valkey is missing from the handlers map, falls back to the default files handler with no log entry, so sessions are written to var/session even though the store is configured for Valkey. The failure is invisible to operators.

The 2.4.9 Valkey work added Magento\Framework\Cache\Backend\Valkey and the --session-save=valkey / --session-save-valkey-* CLI options, but the matching session SaveHandlerFactory registration was never added.

This PR registers the valkey save handler, reusing the Redis-compatible session handler and reading connection parameters from the session/valkey/session/redis deployment-config group.

Related Pull Requests

None.

Fixed Issues (if relevant)

None.

Manual testing scenarios (*)

  1. On a 2.4.9 install with Valkey running, configure Valkey sessions:
bin/magento setup:config:set --session-save=valkey \
--session-save-valkey-host=127.0.0.1 \
--session-save-valkey-port=6379 \
--session-save-valkey-db=2 
bin/magento cache:flush
  1. Open the storefront and create a session (add to cart / log in).
  2. Before: new files appear under var/session, and valkey-cli -n 2 --scan returns no session keys — silent fallback to files.
  3. After: sessions are stored in Valkey — valkey-cli -n 2 --scan returns sess_* keys and valkey-cli -n 2 dbsize grows, while var/session stops growing.
  4. Regression: --session-save=redis, --session-save=db, and --session-save=files continue to work unchanged.

Questions or comments

None.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: P2A defect with this priority could have functionality issues which are not to expectations.

    Type

    No type

    Projects

    Status
    Ready for Development

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions