From dfdf5da3688805035ffff1c4d7f423974b2485bf Mon Sep 17 00:00:00 2001 From: infosave2007 Date: Tue, 11 Nov 2025 19:04:53 +0300 Subject: [PATCH] fix: Improve LDAP configuration loading with table existence check --- inc/LdapSync.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/inc/LdapSync.php b/inc/LdapSync.php index aa7111d..d34fe0f 100644 --- a/inc/LdapSync.php +++ b/inc/LdapSync.php @@ -25,8 +25,22 @@ class LdapSync private function loadConfig(): void { $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 = []; + } } /**