From 975426b01c699a11b40b8db75736622924cdd716 Mon Sep 17 00:00:00 2001 From: theShlavuk Date: Wed, 21 Jan 2026 22:56:46 +0100 Subject: [PATCH] kk --- app/models/TraductionLangue_Model.php | 30 +++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/app/models/TraductionLangue_Model.php b/app/models/TraductionLangue_Model.php index 6d45896..09fc66c 100644 --- a/app/models/TraductionLangue_Model.php +++ b/app/models/TraductionLangue_Model.php @@ -991,8 +991,34 @@ class CRVI_TraductionLangue_Model extends Main_Model { if ($use_cache) { $cached = \get_transient($cache_key); if ($cached !== false) { - error_log('🔍 Cache utilisé pour ' . $cache_key . ' - Résultat: ' . (empty($cached) ? 'vide' : count($cached) . ' langues')); - return $cached; + // Si le cache contient des données, les retourner + if (!empty($cached)) { + error_log('🔍 Cache utilisé pour ' . $cache_key . ' - Résultat: ' . count($cached) . ' langues'); + return $cached; + } + // Si le cache est vide, vérifier s'il y a des capacités actives avant de retourner le cache vide + // Cela évite de retourner un cache vide obsolète + $has_active_capacites = \get_posts([ + 'post_type' => 'traduction_langue', + 'post_status' => 'publish', + 'posts_per_page' => 1, // On vérifie juste s'il y en a au moins une + 'meta_query' => [ + [ + 'key' => 'actif', + 'value' => '1', + 'compare' => '=', + ], + ], + ]); + + if (!empty($has_active_capacites)) { + error_log('⚠️ Cache vide détecté mais des capacités actives existent - invalidation du cache et recalcul'); + \delete_transient($cache_key); + // Continuer pour recalculer + } else { + error_log('🔍 Cache utilisé pour ' . $cache_key . ' - Résultat: vide (aucune capacité active)'); + return []; + } } }