Skip to content

Fix CsvView state reset and 5.x cs-stan setup#147

Merged
dereuromark merged 4 commits into
5.xfrom
fix-5x-pr146-cs-stan
May 11, 2026
Merged

Fix CsvView state reset and 5.x cs-stan setup#147
dereuromark merged 4 commits into
5.xfrom
fix-5x-pr146-cs-stan

Conversation

@dereuromark
Copy link
Copy Markdown
Member

@dereuromark dereuromark commented May 11, 2026

Summary

  • apply the CsvView state reset and extract-path fixes from Fix render-state leak and inconsistent extract path handling #146 on top of 5.x
  • load Slevomat explicitly in phpcs.xml so the current cs-stan workflow resolves all referenced sniffs
  • remove the stale PHPStan ignore and document the extract-path behavior for missing/non-scalar values

Notes

- Convert the per-render static `$csv` / `$fp` locals in
  `_renderRow` / `_generateRow` to instance properties and reset
  them (including `isFirstBom`) at the start of every `_serialize()`
  call. This makes the same view instance safely reusable across
  renders (queue workers, multi-file exports) where the BOM was
  previously emitted only once and the temp stream carried stale
  state between renders.
- Drop the awkward `_resetStaticVariables` flag and the trailing
  `_renderRow()` reset call in `_serialize()`.
- Close the temp stream in `__destruct()` and via the explicit
  `resetState()` helper.
- Route all extract paths through `Hash::get()`. Previously simple
  (non-dotted) keys went through `$_data[$path]` and raised an
  undefined-key warning when the key was missing in some rows;
  dotted paths already returned null via Hash::get.
- Throw a clear `CakeException` when an extract path resolves to
  an array or non-Stringable object instead of silently producing
  "Array to string conversion" notices and corrupted output.

Adds regression tests for: repeat render with BOM on the same
instance, simple extract path with missing key, and array-valued
extract path producing a helpful error.
Comment thread phpcs.xml Outdated
@dereuromark dereuromark merged commit 9cfd520 into 5.x May 11, 2026
7 checks passed
@dereuromark dereuromark deleted the fix-5x-pr146-cs-stan branch May 11, 2026 18:24
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.

2 participants