From 6ac418e27f604dbacb946f9eeb9416701699e1b0 Mon Sep 17 00:00:00 2001 From: Beppe Date: Fri, 7 Feb 2020 12:41:54 +0100 Subject: [PATCH] Esclusione esecuzione hook inutilizzati --- src/Hooks/CachedManager.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Hooks/CachedManager.php b/src/Hooks/CachedManager.php index a0a66b82b..cacfea549 100644 --- a/src/Hooks/CachedManager.php +++ b/src/Hooks/CachedManager.php @@ -52,21 +52,23 @@ abstract class CachedManager extends Manager { $hook = self::getHook(); - // Rimozione cache precedente - $database = database(); - $database->delete('zz_hook_cache', [ - 'hook_id' => $hook->id, - ]); + if( !empty($hook) ){ + // Rimozione cache precedente + $database = database(); + $database->delete('zz_hook_cache', [ + 'hook_id' => $hook->id, + ]); - // Aggiunta del risultato come cache - $cache = json_encode($results); - $database->insert('zz_hook_cache', [ - 'hook_id' => $hook->id, - 'results' => $cache, - ]); + // Aggiunta del risultato come cache + $cache = json_encode($results); + $database->insert('zz_hook_cache', [ + 'hook_id' => $hook->id, + 'results' => $cache, + ]); - self::$cache = $results; - self::$is_cached = null; + self::$cache = $results; + self::$is_cached = null; + } } public static function isCached()