kk
This commit is contained in:
parent
31bc09759a
commit
975426b01c
@ -991,9 +991,35 @@ class CRVI_TraductionLangue_Model extends Main_Model {
|
|||||||
if ($use_cache) {
|
if ($use_cache) {
|
||||||
$cached = \get_transient($cache_key);
|
$cached = \get_transient($cache_key);
|
||||||
if ($cached !== false) {
|
if ($cached !== false) {
|
||||||
error_log('🔍 Cache utilisé pour ' . $cache_key . ' - Résultat: ' . (empty($cached) ? 'vide' : count($cached) . ' langues'));
|
// 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;
|
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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error_log('🔍 Calcul des capacités pour ' . $date_debut . ' à ' . $date_fin);
|
error_log('🔍 Calcul des capacités pour ' . $date_debut . ' à ' . $date_fin);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user