Repository navigation
issue: Show a saved FlowView Filter as it is saved - #300
Merged
Merged
Conversation
The FlowView tab only took a Filter's saved settings when the session held none for it, but it checked for a 'sess_fv_<id>' entry that Cacti never writes (validate_store_request_vars() stores 'sess_fv_<id>_<name>'), so the page fell back to stale session values or its defaults. A saved Sort Field, Listener, Stream, cutoffs, timespan or chart panel did not appear after a save, and a report could keep running for the old Listener. - Seed the page from the saved Filter whenever the session holds nothing for it, and forget the Filter's page settings when it is saved from its editor - Selecting a Filter takes its own Listener, Stream and NAT setting instead of carrying over the ones of the Filter shown before - Save the Stream and custom timespan dates from the FlowView tab Save, keep the Stream with Save As, and save the timespan picked in the editor - Build the Edit/New links without a doubled slash, and have Edit fall back to the Filter the page was drawn for Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Date-session handling can restore an outdated custom range or freeze a relative report window on later visits.
2 open issues
What changed in this PR
Updates FlowView’s saved-filter handling so the report page reflects saved settings and filter selection no longer carries over the previous filter’s Listener, Stream, or NAT setting.
Changes:
- Adds helpers to detect, reset, and initialize filter page settings.
- Persists Stream and custom dates, corrects editor timespan saving, and adjusts Edit/New links.
- Adds regression tests and changelog entries.
| File | Description |
|---|---|
tests/Unit/FilterEditAndSaveTest.php |
Adds coverage for saved settings, session handling, and navigation. |
includes/functions.php |
Updates saving, session helpers, and report-page controls. |
flowview.php |
Initializes saved settings and preserves Stream in Save As. |
CHANGELOG.md |
Documents the saved-filter fixes. |
Review effort: Balanced
…ep preset windows moving - save_filter_form() now forgets the Filter's page settings and cached results, so dates saved without pressing Go are shown on the next visit - flowview_seed_filter_request_vars() no longer seeds the dates of a preset timespan; they stay empty in the session and load_data_for_filter() works them out on every visit, so the window moves with the preset - Cover the helper edge cases for the 100% patch coverage gate Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
xmacan
approved these changes
Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
Fixes several problems with saving a FlowView Filter and showing it on the FlowView tab.
Saved settings never shown (Sort Field, Listener, …)
flowview_request_vars()only seeded the page from the saved Filter when$_SESSION['sess_fv_<id>']was missing. Cacti'svalidate_store_request_vars()never writes that key; it storessess_fv_<id>_<name>. So the check was always true, but the seeded columns were only the chart ones, and the panel seeding was broken (strpos($c, 'panel')is0forpanel_*).validate_store_request_vars()then filled everything else from the session or its defaults, andload_session_for_filter()skipped saved columns that were already set. The result: after a save, the tab kept showing the old Sort Field, Listener, Stream, cutoffs and timespan. A report could also keep running for the old Listener, which made it look as if the cached shards for listener A still applied after the Filter was switched to All.flowview_filter_session_exists(),flowview_reset_filter_session()andflowview_seed_filter_request_vars().save_filter()forgets the Filter's page settings and cached results, so the next view shows it as saved.Selecting a Filter kept the previous Filter's Listener
changeQuery()sent the current page'sdevice_id,ex_addrandusenatalong with the newly selected filter, which overrode the selected Filter's own values. The time window and Domains toggle are still carried over.Fields that were not saved
save_filter_form()) now stores the Stream (ex_addr, with "no stream" stored as All) and the custom timespan dates. The Stream also counts toward the re-materialize check.predefined_timespan, but the save readtimespan, so it was always stored as Custom (0).Edit button
I couldn't reproduce Edit → "Filter: [new]" on Cacti 1.2.32. As a defensive fix, Edit/New now build
urlPath + 'plugins/...'(previously'/plugins/...', which gives//plugins/...and is protocol-relative when Cacti is at/). Edit also falls back to the Filter id the page was rendered for.Testing
tests/Unit/FilterEditAndSaveTest.php(14 new cases). Security and Unit suites: 373 passed. The 4 materialize tests that fail locally fail the same way on unmodifieddevelop(Windows shell quoting only).flows).