Skip to content

feat(profiler): trace filter state persistence - #53

Open
gilles-g wants to merge 2 commits into
masterfrom
feat/filter-state-persistence
Open

feat(profiler): trace filter state persistence#53
gilles-g wants to merge 2 commits into
masterfrom
feat/filter-state-persistence

Conversation

@gilles-g

@gilles-g gilles-g commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Opt-in persistence of the filter state (12.3): filter_persistence makes
$form->handleRequest($request) remember what was submitted and restore it on requests
carrying no filter data. Off by default, no public signature changed.

$form = $this->createForm(ItemFilterType::class, null, [
    'filter_persistence' => true,
    'csrf_protection' => false,
]);
$form->handleRequest($request);

Contents

- FilterState — holds the view data (strings/arrays only), restores via $form->submit().
- FilterStateStorageInterface — SessionFilterStateStorage (default), NullFilterStateStorage.
- FilterStateRequestHandler — stores a valid submission, restores, drops an invalid restoration,
  honours _reset (persistence.reset_parameter).
- FilterStateTypeExtension — declares the option, installs the handler.
- FilterUrlGenerator — permalinks.
- TraceableFilterStateStorage — profiler Persistence section in debug.

Review points

- No session is ever started: no previous session or stateless route ⇒ no persistence.
  Keeps anonymous listings cookie-free and cacheable.
- CSRF must be off on a persisted form (a token can't be replayed) — LogicException otherwise.
- The tracer reads the state back after writing: a storage that kept nothing shows not_stored,
  never saved. It decorates the interface alias, so custom storages are traced too.
- symfony/http-foundation + symfony/routing move to require (already transitive);
  symfony/security-csrf to require-dev.

@gilles-g

gilles-g commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@alioguz Hi,

if you want to have a look or test the feature. I admit the code was made with claude ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant