Skip to content

feat: add the database-backed session handler and persistence - #4

Merged
tyrsson merged 2 commits into
1.0.xfrom
feat/session
Oct 1, 2026
Merged

tyrsson merged 2 commits into
1.0.xfrom
feat/session

Conversation

@tyrsson

@tyrsson tyrsson commented Sep 30, 2026

Copy link
Copy Markdown
Member

Moves the session handler and persistence from the IMS copy of php-db/phpdb-mezzio-session into this bridge, under PhpDb\Session (the namespace that package presents). IMS is only read.

  • DbSessionHandler (ext-session handler), PhpDbSessionPersistence (mezzio persistence, async-safe) and the upsert Sql\Insert.
  • session:init-db creates the table. Columns are taken from the IMS schema (data/schema/015_session.sql): id VARCHAR(64) PK, payload MEDIUMTEXT, modified_at, expires_at (indexed). The database-side timestamp defaults are not carried over: every write supplies both.
  • SessionProvider is a second extra.laminas.config-provider and aliases SessionPersistenceInterface to the database persistence. mezzio/mezzio-session and webware/webware-console are require-dev plus suggest, not requirements.

Changed from the source rather than copied: table name from one SessionTable enum, settings through IniDefaults, payload encoding in SessionPayload, declared exceptions, named arguments, fromConfigArray() folded into the constructor. No baseline entries added.

Known limits, unchanged from the source:

  • Sql\Insert hardcodes MySQL ON DUPLICATE KEY UPDATE (the source has the same @todo); the integration tests run on MySQL only.
  • gc() keeps $maxLifetime; the interface names it $max_lifetime, which the camel-case lint rule rejects, so the analyzer warns.

Verification: format, lint, analyze and guard clean. 58 unit tests. Integration on a throwaway MySQL 9.7: handler, persistence, factory wiring, and the created table compared column by column with the IMS definition. Coverage 100% lines. Infection on src/Session: 138 mutants, 0 escaped.

Not from this PR: SchemaFactoryIntegrationTest::itCreatesPrefixedTableOnMysql already fails on 1.0.x (calls the now-private WebwareProvider::getDependencies()), which also stops Infection from starting its initial run. I excluded it locally and did not touch it. WebwareProviderWiringTest is updated because config-provider is now a list.

A release of webware-phpdb is needed before hosts can use this without a path repo.

Moves the PhpDb session handler, the mezzio session persistence and their upsert Insert out of the IMS copy of php-db/phpdb-mezzio-session into this bridge, under the PhpDb\Session namespace it presents. Nothing is deleted from IMS.

The code is brought up to the stack standards rather than copied verbatim: the table name comes from one SessionTable enum, settings resolve through IniDefaults, payload encoding is SessionPayload, exceptions are declared, and every finding is fixed at source with no baseline entry.

session:init-db creates the table. Its columns come from the IMS session schema (id, payload, modified_at, expires_at; primary key id; index on expires_at), less the database-side timestamp defaults because every write supplies both timestamps.

SessionProvider is a second config provider and aliases SessionPersistenceInterface to the database persistence. mezzio-session and webware-console are dev dependencies and suggestions, not requirements.

Signed-off-by: Joey Smith <jsmith@webinertia.net>
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tyrsson tyrsson self-assigned this Oct 1, 2026
@tyrsson tyrsson added the enhancement New feature or request label Oct 1, 2026
@tyrsson
tyrsson merged commit cf6b568 into 1.0.x Oct 1, 2026
12 checks passed
@tyrsson
tyrsson deleted the feat/session branch October 1, 2026 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant