Skip to content

Commit 58f8b92

Browse files
committed
fix: reset cache hooks per evitare avviso cron non impostato correttamente
1 parent 7896fdc commit 58f8b92

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

update/2_10_1.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
include __DIR__.'/../config.inc.php';
4+
use Carbon\Carbon;
5+
use Models\Cache;
6+
7+
// 1. Sblocca tutti gli hooks che potrebbero essere bloccati
8+
$unlocked_hooks = $database->table('zz_hooks')
9+
->update([
10+
'processing_at' => null,
11+
'processing_token' => null,
12+
]);
13+
14+
// 2. Invalida tutte le cache degli hooks impostando la scadenza nel passato
15+
$cache_affected = $database->table('zz_cache')
16+
->update(['expire_at' => Carbon::now()->subMinutes(1)]);
17+
18+
// 3. Svuota il contenuto delle cache specifiche degli hooks
19+
$hook_caches = [
20+
'Informazioni su Services',
21+
'Spazio utilizzato',
22+
'Ultima versione di OpenSTAManager disponibile',
23+
'Ricevute Elettroniche',
24+
'Ultima esecuzione del cron',
25+
];
26+
27+
$content_cleared = 0;
28+
foreach ($hook_caches as $cache_name) {
29+
$cache = Cache::where('name', $cache_name)->first();
30+
if ($cache) {
31+
$cache->content = null;
32+
$cache->expire_at = Carbon::now()->subMinutes(1);
33+
$cache->save();
34+
++$content_cleared;
35+
}
36+
}
37+
38+
// 4. Rimuovi fisicamente le cache scadute (solo quelle temporanee)
39+
$deleted_rows = $database->table('zz_cache')
40+
->where('expire_at', '<', Carbon::now())
41+
->whereNull('valid_time')
42+
->delete();

update/2_10_1.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ DELETE FROM `zz_views` WHERE `name` = 'Descrizione' AND `id_module` = (SELECT `i
4141

4242
-- Fix colonna mancante dt_statiddt
4343
ALTER TABLE `dt_statiddt` ADD `can_delete` INT NOT NULL DEFAULT '1' AFTER `is_fatturabile`;
44-
UPDATE `dt_statiddt` SET `can_delete` = 0 WHERE `name` IN ('Bozza', 'Evaso', 'Fatturato', 'Parzialmente fatturato', 'Parzialmente evaso')
44+
UPDATE `dt_statiddt` SET `can_delete` = 0 WHERE `name` IN ('Bozza', 'Evaso', 'Fatturato', 'Parzialmente fatturato', 'Parzialmente evaso');
4545

4646
-- Fix riferimenti plugin
4747
UPDATE `zz_plugins` SET `idmodule_from` = (SELECT `id` FROM `zz_modules` WHERE `name` = "Fatture di acquisto") WHERE (`zz_plugins`.`name` = "Fatturazione elettronica" AND `idmodule_to` = (SELECT `id` FROM `zz_modules` WHERE `name` = "Fatture di acquisto"));

0 commit comments

Comments
 (0)