This commit is contained in:
2025-12-08 01:10:49 +01:00
parent ae4f32abce
commit e50bf86062

View File

@@ -1669,7 +1669,11 @@ class ApiKernel
$customerId = (int)($user['customer_id'] ?? 0); $customerId = (int)($user['customer_id'] ?? 0);
if ($customerId <= 0) $this->fail('Customer context missing', null, 500); if ($customerId <= 0) $this->fail('Customer context missing', null, 500);
$table = $this->senderTable(); $table = $this->senderTable();
try {
$stmt = $this->pdo->prepare("SELECT * FROM `$table` WHERE `customer_id` = :cid ORDER BY `label` ASC"); $stmt = $this->pdo->prepare("SELECT * FROM `$table` WHERE `customer_id` = :cid ORDER BY `label` ASC");
} catch (Throwable $e) {
$this->fail('Sender-Tabelle existiert nicht', $e->getMessage(), 500);
}
$stmt->execute([':cid' => $customerId]); $stmt->execute([':cid' => $customerId]);
$items = []; $items = [];
while ($row = $stmt->fetch()) { while ($row = $stmt->fetch()) {
@@ -1995,9 +1999,8 @@ class ApiKernel
private function ensureCustomerSettingsTableExists(): void private function ensureCustomerSettingsTableExists(): void
{ {
$table = $this->customerSettingsTable(); $table = $this->customerSettingsTable();
if ($this->tableExists($table)) { if ($this->tableExists($table)) return;
return; try {
}
$sql = <<<SQL $sql = <<<SQL
CREATE TABLE IF NOT EXISTS `$table` ( CREATE TABLE IF NOT EXISTS `$table` (
`customer_id` int(10) unsigned NOT NULL, `customer_id` int(10) unsigned NOT NULL,
@@ -2013,6 +2016,9 @@ CREATE TABLE IF NOT EXISTS `$table` (
SQL; SQL;
$this->pdo->exec($sql); $this->pdo->exec($sql);
$this->tableExistsCache[$table] = true; $this->tableExistsCache[$table] = true;
} catch (Throwable $e) {
$this->fail('Customer-Settings Tabelle fehlt und konnte nicht erstellt werden', $e->getMessage(), 500);
}
} }
private function generateToken(int $length = 48): string private function generateToken(int $length = 48): string