mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-09-25 01:53:03 +02:00
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:
+12
-2
@@ -15,7 +15,11 @@ class TestDatabaseInstance extends Database
|
||||
{
|
||||
public function __construct(PDO $pdo)
|
||||
{
|
||||
// Inject PDO directly via reflection, then flag as ready
|
||||
// Inject PDO directly via reflection, then flag as ready.
|
||||
// Because we bypass the parent constructor, we must also register the
|
||||
// custom SQLite functions (e.g. accfold) it would otherwise install.
|
||||
Database::registerSqliteFunctions($pdo);
|
||||
|
||||
$ref = new ReflectionProperty(Database::class, 'pdo');
|
||||
$ref->setValue($this, $pdo);
|
||||
|
||||
@@ -36,7 +40,13 @@ class TestDatabase
|
||||
public static function getInstance(): Database
|
||||
{
|
||||
if (self::$db === null) {
|
||||
self::$pdo = new PDO('sqlite::memory:');
|
||||
// Since PHP 8.5, `PDO::sqliteCreateFunction()` is deprecated and the
|
||||
// registration in Database::registerSqliteFunctions() uses
|
||||
// `Pdo\Sqlite::createFunction()` when the connection is a `Pdo\Sqlite`.
|
||||
// Build the same connection type here so the new API path is exercised.
|
||||
self::$pdo = class_exists('Pdo\Sqlite')
|
||||
? new Pdo\Sqlite('sqlite::memory:')
|
||||
: new PDO('sqlite::memory:');
|
||||
self::$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
self::$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
self::$pdo->exec('PRAGMA foreign_keys = ON');
|
||||
|
||||
Reference in New Issue
Block a user