diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-12-01 10:30:19 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-12-19 14:15:48 +0100 |
commit | 406750552e1332f4419cd0c8b77891c1e8b4aee1 (patch) | |
tree | 18ddf7e77b52648cc0dde8736b8d2e10529d5177 /apps/user_ldap/lib | |
parent | 4758bdc476f0b2ed981b40bff46239d2a64718fa (diff) | |
download | nextcloud-server-406750552e1332f4419cd0c8b77891c1e8b4aee1.tar.gz nextcloud-server-406750552e1332f4419cd0c8b77891c1e8b4aee1.zip |
Make code clearer for background host
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/Connection.php | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index a144810b39b..1cde3bc3960 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -598,16 +598,16 @@ class Connection extends LDAPUtility { } } - $isOverrideMainServer = ($this->configuration->ldapOverrideMainServer - || $this->getFromCache('overrideMainServer')); - $isBackupHost = (trim($this->configuration->ldapBackupHost) !== "") - && (!\OC::$CLI || !$this->configuration->ldapBackgroundHost); + $forceBackupHost = ($this->configuration->ldapOverrideMainServer || $this->getFromCache('overrideMainServer')); + $hasBackupHost = (trim($this->configuration->ldapBackupHost ?? '') !== ''); + $hasBackgroundHost = (trim($this->configuration->ldapBackgroundHost ?? '') !== ''); + $useBackupHost = $hasBackupHost && (!\OC::$CLI || !$hasBackgroundHost); $bindStatus = false; try { - if (!$isOverrideMainServer) { + if (!$forceBackupHost) { $host = $this->configuration->ldapHost; $port = $this->configuration->ldapPort; - if (\OC::$CLI && $this->configuration->ldapBackgroundHost) { + if (\OC::$CLI && $hasBackgroundHost) { $host = $this->configuration->ldapBackgroundHost; $port = $this->configuration->ldapBackgroundPort; } @@ -615,7 +615,7 @@ class Connection extends LDAPUtility { return $this->bind(); } } catch (ServerNotAvailableException $e) { - if (!$isBackupHost) { + if (!$useBackupHost) { throw $e; } $this->logger->warning( @@ -627,7 +627,7 @@ class Connection extends LDAPUtility { } //if LDAP server is not reachable, try the Backup (Replica!) Server - if ($isBackupHost || $isOverrideMainServer) { + if ($useBackupHost || $forceBackupHost) { $this->doConnect($this->configuration->ldapBackupHost, $this->configuration->ldapBackupPort); $this->bindResult = []; |