fix: Cronjob entfernt, Cleanup opportunistisch beim Token-Create
All checks were successful
Deploy bericht / deploy (push) Successful in 1s
All checks were successful
Deploy bericht / deploy (push) Successful in 1s
Der Dolibarr-Cron-Scheduler ist auf Prod nicht aktiv, deshalb hing der tägliche Cleanup-Job 'Expired Upload-Tokens bereinigen' auf 'Geplant' und GlobalNotify meldete ihn als hängenden Job. Lösung: Cronjob komplett aus dem Modul entfernt. Das Cleanup läuft jetzt opportunistisch bei jedem neuen Token-Insert: BerichtUploadToken::create() führt vor dem INSERT ein DELETE FROM llx_bericht_upload_token WHERE expires_at < NOW() aus. Das ist minimal teurer (1 Query extra pro Token-Create, ~0ms bei leerer Tabelle), aber vollständig cron-unabhängig. WICHTIG für Prod: Nach Deploy muss der bestehende Cron-Eintrag manuell aus llx_cronjob gelöscht werden (oder das Modul einmal deaktiviert + reaktiviert werden, dann wird er mit remove() bzw. init() neu gesetzt — ohne Eintrag). GlobalNotify ist danach ruhig. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> [deploy]
This commit is contained in:
parent
344f884a0f
commit
1705744809
2 changed files with 8 additions and 17 deletions
|
|
@ -25,10 +25,15 @@ class BerichtUploadToken
|
|||
|
||||
/**
|
||||
* Erstellt einen neuen Token für einen Bericht.
|
||||
* Räumt dabei abgelaufene Tokens gleich mit auf (kein Cronjob nötig).
|
||||
* @return string|false Hex-Token bei Erfolg
|
||||
*/
|
||||
public function create($fk_bericht, $fk_user, $lifetime = null, $max_uploads = null)
|
||||
{
|
||||
// Opportunistisches Cleanup: entferne abgelaufene Tokens bei jedem Insert
|
||||
$this->db->query("DELETE FROM ".$this->db->prefix()."bericht_upload_token"
|
||||
." WHERE expires_at < '".$this->db->idate(dol_now())."'", 1);
|
||||
|
||||
$this->token = bin2hex(random_bytes(32));
|
||||
$this->fk_bericht = (int) $fk_bericht;
|
||||
$this->fk_user_creat = (int) $fk_user;
|
||||
|
|
|
|||
|
|
@ -89,23 +89,9 @@ class modBericht extends DolibarrModules
|
|||
|
||||
$this->dictionaries = array();
|
||||
$this->boxes = array();
|
||||
// Cleanup expired Mobile-Upload-Tokens (täglich um 03:30)
|
||||
$this->cronjobs = array(
|
||||
0 => array(
|
||||
'label' => 'Bericht: Expired Upload-Tokens bereinigen',
|
||||
'jobtype' => 'method',
|
||||
'class' => '/bericht/class/upload_token.class.php',
|
||||
'objectname' => 'BerichtUploadToken',
|
||||
'method' => 'cleanupExpired',
|
||||
'parameters' => '',
|
||||
'comment' => 'Löscht abgelaufene Mobile-Upload-Tokens aus llx_bericht_upload_token',
|
||||
'frequency' => 1,
|
||||
'unitfrequency' => 86400,
|
||||
'status' => 1,
|
||||
'test' => 'isModEnabled("bericht")',
|
||||
'priority' => 50,
|
||||
),
|
||||
);
|
||||
// Kein Cronjob — Cleanup expired Upload-Tokens passiert on-demand
|
||||
// beim Anlegen eines neuen Tokens (siehe BerichtUploadToken::create()).
|
||||
$this->cronjobs = array();
|
||||
|
||||
// Rechte — wie Stundenzettel: [4]=perms, [5]=subperms (leer)
|
||||
$this->rights = array();
|
||||
|
|
|
|||
Loading…
Reference in a new issue