fix: author name casing not updating — use ID lookup priority

Root cause: SQLite uses BINARY collation, so WHERE name = ? is
case-sensitive. When changing 'john doe' to 'John Doe', the name
lookup failed and fell through to the email path which didn't update
the name. The previous fix only added UPDATE in the name-match branch.

Fixes in findOrCreateAuthor:
1. Accept optional $idHint parameter — when known (edit flow), update
   directly by ID (fastest, zero ambiguity)
2. Add COLLATE NOCASE to the name lookup (fallback path)
3. Add UPDATE in the email fallback path too

setThesisAuthors now fetches existing author_ids before deletion and
passes them as position-based hints, so identity is always preserved.
This commit is contained in:
Pontoporeia
2026-06-09 12:33:26 +02:00
parent 3016c199bd
commit 3df1456781
12 changed files with 62 additions and 16 deletions

View File

@@ -2,8 +2,10 @@
- [x] Fix #1: TFE publié se dépublie quand on modifie ses données (is_published missing from getThesisRawFields SELECT)
- [x] Fix #2: Renommer "Note contextuelle" → "Note contextuelle relative à soutenance"
- [x] Fix #3: Impossible de mettre une majuscule au nom d'étudiant·e (findOrCreateAuthor n'update pas le name)
- [x] Fix #3: Impossible de mettre une majuscule au nom d'étudiant·e — la recherche par nom en SQLite est case-sensitive (BINARY), contournait le UPDATE et tombait dans le fallback email sans updater le nom. Ajout COLLATE NOCASE + UPDATE dans le chemin email.
- [x] Fix #4: Décorréler contact interne et contact visible (ajouter colonne contact_visible sur theses)
- [x] Fix #5: "Contact public : non" partout, non modifiable, sans impact
- [x] Fix #6: Investiguer "libre → interne" impossible — aucune restriction trouvée dans le code admin, probablement causé par Fix #1 (is_published reset)
- [ ] Commit + jj new
- [x] Fix #6: Investiguer "libre → interne" impossible — aucune restriction trouvée dans le code admin
- [x] Hotfix: contact_visible manquant dans le SQL de updateThesis (l'edit matchait createThesis à la place)
- [x] Fix #7: Options de licence non persistées en edit — HTMX load trigger perdait les valeurs (pas de hidden inputs pour license_id/license_custom/cc2r/want_license dans fieldset-licence-explanation.php)
- [x] Commit + jj new