fix: Improve LDAP configuration loading with table existence check

This commit is contained in:
infosave2007
2025-11-11 19:04:53 +03:00
parent 669baf1ba7
commit dfdf5da368
+16 -2
View File
@@ -25,8 +25,22 @@ class LdapSync
private function loadConfig(): void private function loadConfig(): void
{ {
$db = DB::conn(); $db = DB::conn();
$stmt = $db->query("SELECT * FROM ldap_configs WHERE id = 1");
$this->config = $stmt->fetch(PDO::FETCH_ASSOC) ?: []; // Check if ldap_configs table exists
try {
$stmt = $db->query("SHOW TABLES LIKE 'ldap_configs'");
if (!$stmt->fetch()) {
// Table doesn't exist yet - use empty config
$this->config = [];
return;
}
$stmt = $db->query("SELECT * FROM ldap_configs WHERE id = 1");
$this->config = $stmt->fetch(PDO::FETCH_ASSOC) ?: [];
} catch (PDOException $e) {
// If any error occurs, use empty config
$this->config = [];
}
} }
/** /**