findologic / libflexport

FINDOLOGIC export toolkit for XML and CSV data export
MIT License
4 stars 5 forks source link

Fix flaw in pagination for CSV file serialization #123

Closed TheKeymaster closed 4 years ago

TheKeymaster commented 4 years ago

Purpose

There is a flaw in pagination for CSV file pagination. The file is always cleared after calling serializeItemsToFile, this makes the pagination completely useless.

Fun fact:

Calling the pagination with start 1 caused the CSV to be completely invalid, as the header is only written if the count is > 0 :laughing:

Approach

In \FINDOLOGIC\Export\CSV\CSVExporter::serializeItemsToFile when calling file_put_contents add the flag FILE_APPEND. PHP documentation:

If file filename already exists, append the data to the file instead of overwriting it.

Open Questions and Pre-Merge TODOs

codecov-io commented 4 years ago

Codecov Report

Merging #123 into develop will not change coverage by %. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##             develop      #123   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       269       270    +1     
===========================================
  Files             49        49           
  Lines            700       700           
===========================================
  Hits             700       700           
Flag Coverage Δ Complexity Δ
#unittests 100.00% <100.00%> (ø) 270.00 <0.00> (+1.00)
Impacted Files Coverage Δ Complexity Δ
src/FINDOLOGIC/Export/CSV/CSVExporter.php 100.00% <100.00%> (ø) 10.00 <0.00> (+1.00)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 360ae30...3caf007. Read the comment docs.