Skip to content

Fix: CSV export file missing IP column - #237

Merged
KingYes merged 3 commits into
masterfrom
fix/csv-export-missing-ip
Aug 26, 2026
Merged

Fix: CSV export file missing IP column#237
KingYes merged 3 commits into
masterfrom
fix/csv-export-missing-ip

Conversation

@KingYes

@KingYes KingYes commented Aug 26, 2026

Copy link
Copy Markdown
Member

✨ PR Description

1. Problem & Context

CSV exports were missing the IP column entirely. The fix ensures IP data is included in exports when the setting permits collection, addressing data completeness in audit logs.

2. What Changed (Where)

  • class-aal-export.php: Added add_export_ip_column() private method that conditionally inserts IP column after source column (respecting IP collection settings)
  • test-export.php: New test suite with 5 cases covering IP column insertion, omission, and fallback positioning

3. How It Works

When exporting, the code retrieves columns from the list table, then calls add_export_ip_column() which:

  1. Returns early if IP collection is disabled ('no-collect-ip')
  2. Iterates columns, inserting IP after 'source' key if present
  3. Appends IP to end if source column absent (fallback)

Existing prep_row() already populates $row['ip'] from $item->hist_ip, so no data flow changes needed.

4. Risks

Low risk. Settings check prevents exporting when collection disabled. Column insertion is append-only (doesn't mutate existing columns). Test coverage validates three placement scenarios, though integration test with actual CSV generation would strengthen confidence.

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how

@KingYes
KingYes merged commit 834f805 into master Aug 26, 2026
53 checks passed
@KingYes
KingYes deleted the fix/csv-export-missing-ip branch August 26, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant