search: index plat search_index.json, reconstruit sur chaque write

This commit is contained in:
Cedric Abonnel
2026-05-12 01:40:22 +02:00
parent f236ea24de
commit 045e93cffd
9 changed files with 290 additions and 5 deletions
+7 -1
View File
@@ -1508,7 +1508,13 @@ switch ($action) {
$searchResults = [];
if ($searchQuery !== '') {
$privateCats = $articles->getPrivateCategories();
$searchPool = array_values(array_filter($articles->getAll(true), static function (array $a) use ($privateCats): bool {
// Utilise l'index pré-construit si disponible (lecture d'un seul fichier JSON)
// Sinon fallback sur getAll() qui scanne tous les répertoires
$rawPool = $articles->getSearchIndex() ?? $articles->getAll(true);
$searchPool = array_values(array_filter($rawPool, static function (array $a) use ($privateCats): bool {
if (!($a['published'] ?? false)) {
return false;
}
$cat = trim($a['category'] ?? '');
if ($cat !== '' && in_array($cat, $privateCats, true) && !isLoggedIn()) {
return false;