fix: auto-regenerate thesis identifier on any year-prefix mismatch, support .php migrations in runner

ThesisEditController::save() previously only regenerated the identifier when
the year field changed during an edit. If a thesis had its year corrected in
a past edit (or via other means) and the identifier still carried the old
year prefix, subsequent edits that didn't touch the year field would leave
the mismatched identifier in place.

Now saves() also checks whether the existing identifier's 4-digit prefix
matches the thesis year, and regenerates if not — regardless of whether year
changed in the current edit.

The migration runner (run.php) only scanned for .sql files, so PHP migrations
(013, 016, 018, 038) were never auto-applied. Extended the runner to also
discover and execute .php migrations in a subprocess. If a PHP migration fails
with an idempotent error (no such column, already exists, duplicate column),
the runner treats it as already-applied and continues rather than aborting
— preventing a stale migration like 016 (banner_path already dropped by 028)
from blocking migrations that come after it alphabetically (e.g. 038).

Updated migrations 016 and 038 to accept an optional $argv[1] DB path.
Fixed 016 to gracefully handle the banner_path column already being gone
(exit 0 instead of fatal).
This commit is contained in:
Pontoporeia
2026-06-09 13:40:46 +02:00
parent 07370b7221
commit 021c58925e
5 changed files with 75 additions and 14 deletions

View File

@@ -12,4 +12,11 @@
- [x] Migration 038: corriger les identifiers theses qui ne matchent pas leur année
- [x] Filtres finalité + format dans la page de recherche (search.php)
- [x] Styliser boutons Filtrer/Réinitialiser : plus compacts, Réinitialiser en neutre
- [ ] Commit + jj new
- [x] Commit + jj new
- [x] Fix identifier-year mismatch: extend save() to regenerate identifier when prefix doesn't match year (not just on year change)
- [x] Fix migration runner run.php to support .php migrations alongside .sql
- [x] Fix runner: treat PHP subprocess idempotent errors (no such column / already exists) as skippable rather than fatal
- [x] Update 016 and 038 PHP migrations to accept $argv[1] DB path
- [x] Fix migration 016 to gracefully handle banner_path column already being dropped
- [x] Commit + jj new