Recherche insensible aux accents sur toutes les barres de recherche (publique + backoffice).

Ajoute une fonction SQLite UDF accfold() (app/src/AccentFolding.php) qui plie les caractères accentués latin vers leur base ASCII (é→e, ç→c, …), et l'applique à chaque condition de recherche côté colonne ET côté terme (accfold(column) LIKE accfold(:term)). Comme le runtime n'a ni intl (Normalizer) ni iconv, le repli passe par une map de translitération manuelle (Western Latin-1 + Latin Extended-A, NULL-safe).

Couvert :
- recherche publique (searchTheses / countSearchResults) : titre, sous-titre, synopsis, auteurs, promoteurs, tags ;
- popover étudiant (getThesesByAuthorName / getThesesForAuthors) : a.name ;
- recherche backoffice (getThesesList / getThesesListCount) : titre, sous-titre, identifiant, auteur.

L'UDF est enregistré dans Database::registerSqliteFunctions() (appelé par le constructeur et par le harnais de test TestDatabaseInstance). Évite aussi la dépréciation PHP 8.5 de PDO::sqliteCreateFunction() : la connexion est créée via \Pdo\Sqlite quand disponible (createFunction()) avec repli sur PDO (sqliteCreateFunction()) sur les anciens runtimes ; les tests passent de @dataProvider docblock à l'attribut #[DataProvider] (fin de la dépréciation PHPUnit). Détache .php-cs-fixer.cache (gitignoré) pour ne plus polluer le working copy.

294 tests PHPUnit verts sans dépréciation, phpstan niveau 5 OK.
This commit is contained in:
Pontoporeia
2026-09-18 16:26:36 +02:00
parent 0896c4b8c8
commit a31e4ab307
7 changed files with 341 additions and 32 deletions
+20
View File
@@ -77,6 +77,26 @@ Queries operate on `v_theses_public`; keyword matching joins the `thesis_tags` /
All queries use PDO prepared statements and escape `%`/`_` for `LIKE`
(`Database::escapeLikeString`) to prevent wildcard injection.
### Accent-insensitive matching
Text searches on the public **search bar**, the **student-preview** popover, and
the **admin list** search are all **diacritic-insensitive**: `Théophile` and
`Theophile`, `sévère` and `severe` return the same results.
This is implemented via a SQLite user-defined function `accfold()`
(`app/src/AccentFolding.php`, registered in `Database::registerSqliteFunctions()`), which
strips precomposed accented Latin characters to their ASCII base (`é` → `e`,
`ç` → `c`, …). Search conditions compare the folded column against the folded
term (`accfold(column) LIKE accfold(:term)`), so both sides are normalised the
same way. The function is NULL-safe and registered on the production and test
connections alike; the public path uses `searchTheses()`/`countSearchResults()`,
the student popover `getThesesByAuthorName()`, and the admin list
`getThesesList()`/`getThesesListCount()`.
Note: `intl`/`Normalizer` and `iconv` are **not** available on the runtime, so
folding uses a hand-maintained transliteration map (Western Latin-1 +
Latin Extended-A).
---
## Performance notes