add structured logging for admin/partage form submissions + migration system

- AppLogger: JSON-line logger in storage/logs/form-submissions.log
- Logs submissions (admin + partage) with IP, UA, thesis ID, author
- Logs errors with context (post keys, share slug)
- Migration runner (app/migrations/run.php) handles schema drift
- 001_add_objet_column.sql fixes production DB missing 'objet' column
- ThesisCreateController::getIdentifier() helper for logging
This commit is contained in:
Pontoporeia
2026-04-24 16:55:11 +02:00
parent decb9e2907
commit 4986fa74f4
9 changed files with 344 additions and 10 deletions

20
TODO.md
View File

@@ -3,6 +3,16 @@
## Fixes
- [x] Replace `mb_strtolower` with `strtolower` in admin/index.php (mbstring not available in php8.4-fpm)
- [x] Replace `mb_strlen`/`mb_substr` with `strlen`/`substr` in student-preview.php (same root cause)
- [x] Add `objet` column migration (production DB missing column → SQLSTATE[HY000]: table theses has no column named objet)
## Logging
- [x] `AppLogger` — structured JSON logger at `storage/logs/form-submissions.log`
- [x] Admin formulaire: log submissions (success + error, IP, UA, author, post keys)
- [x] Partage form: log submissions (success + error, share slug, IP, UA, post keys)
## Migrations
- [x] Migration runner (`app/migrations/run.php`) with tracking table `_migrations`
- [x] `001_add_objet_column.sql` (handles duplicate-column gracefully)
## Features
- [x] Student name popover preview in /repertoire (zero per-hover requests)
@@ -13,3 +23,13 @@
- [x] Updated `repertoire-index.php` — htmx hover attrs, `$studentWorks` map
- [x] Popover container + JS position/hide logic in `repertoire.php`
- [x] CSS in `repertoire.css`
## File naming
- [x] Analyse current file saving in admin/add.php and partage/index.php
- [x] Implement author slug generation (`generateAuthorSlug`)
- [x] Modify `handleThesisFiles`: folder = `theses/{year}/{year}_{AUTHOR_NAME}/`
- [x] Modify `handleThesisFiles`: filename = `AUTHOR_NAME_sanitized_original.ext`
- [x] Ensure uniqueness within same year/author (suffix `_1`, `_2`, etc.)
- [x] Database path storage updated automatically via `insertThesisFile`
- [ ] Test with actual uploads
- [ ] Consider same changes for `handleCoverUpload` and `handleBannerUpload`