[FIX] Database::execute() → Database::query() in 5 controller

Database non ha metodo execute() — corretto in:
InviteController, ServicesController, WebhookController,
NormativeController, WhistleblowingController.
Causa del HTTP 500 su tutti gli endpoint /api/invites/*.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
DevEnv nis2-agile
2026-03-07 16:49:58 +01:00
co-authored by Claude Sonnet 4.6
parent c906a6eff3
commit 9ccf2a72b5
5 changed files with 22 additions and 22 deletions
+7 -7
View File
@@ -85,7 +85,7 @@ class InviteController extends BaseController
$tokenHash = hash('sha256', $rawToken);
$prefix = substr($rawToken, 0, 10) . '...';
Database::execute(
Database::query(
'INSERT INTO invites
(token_prefix, token_hash, plan, duration_months, label, notes,
max_uses, max_users_per_org, price_eur, reseller_name,
@@ -153,7 +153,7 @@ class InviteController extends BaseController
if ($channel) { $where[] = 'channel = ?'; $params[] = $channel; }
// Auto-scaduti: aggiorna status se expires_at passato
Database::execute(
Database::query(
"UPDATE invites SET status='expired' WHERE status='pending' AND expires_at < NOW()"
);
@@ -213,7 +213,7 @@ class InviteController extends BaseController
if (!$row) $this->jsonError('Invito non trovato', 404, 'NOT_FOUND');
if ($row['status'] === 'used') $this->jsonError('Invito già usato — non revocabile', 422, 'ALREADY_USED');
Database::execute("UPDATE invites SET status='revoked', updated_at=NOW() WHERE id=?", [$id]);
Database::query("UPDATE invites SET status='revoked', updated_at=NOW() WHERE id=?", [$id]);
$this->logAudit('invite.revoked', 'invite', $id);
$this->jsonSuccess(['revoked' => true, 'id' => $id]);
}
@@ -234,7 +234,7 @@ class InviteController extends BaseController
$tokenHash = hash('sha256', $rawToken);
$prefix = substr($rawToken, 0, 10) . '...';
Database::execute(
Database::query(
"UPDATE invites SET token_prefix=?, token_hash=?, status='pending', updated_at=NOW() WHERE id=?",
[$prefix, $tokenHash, $id]
);
@@ -312,7 +312,7 @@ class InviteController extends BaseController
}
if (strtotime($invite['expires_at']) < time()) {
Database::execute("UPDATE invites SET status='expired' WHERE id=?", [$invite['id']]);
Database::query("UPDATE invites SET status='expired' WHERE id=?", [$invite['id']]);
return ['valid' => false, 'invite' => $invite, 'error' => 'Invito scaduto il ' . $invite['expires_at'], 'code' => 'EXPIRED'];
}
@@ -324,7 +324,7 @@ class InviteController extends BaseController
*/
public static function markUsed(int $inviteId, int $orgId, string $ip): void
{
Database::execute(
Database::query(
"UPDATE invites
SET used_count = used_count + 1,
status = CASE WHEN used_count + 1 >= max_uses THEN 'used' ELSE 'pending' END,
@@ -423,7 +423,7 @@ class InviteController extends BaseController
}
// Aggiorna last_used_at
Database::execute('UPDATE api_keys SET last_used_at=NOW() WHERE id=?', [$key['id']]);
Database::query('UPDATE api_keys SET last_used_at=NOW() WHERE id=?', [$key['id']]);
return;
}