[Pkg-owncloud-commits] [owncloud] 14/103: do not hide exception when ldap server has a hiccup
David Prévot
taffit at moszumanska.debian.org
Sun May 31 12:32:33 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v8.0.4RC1
in repository owncloud.
commit 01328b46229a0c574b262b84bba6035ede06454e
Author: Jörn Friedrich Dreyer <jfd at butonic.de>
Date: Tue Mar 31 13:42:23 2015 +0200
do not hide exception when ldap server has a hiccup
---
apps/user_ldap/lib/connection.php | 3 ++-
apps/user_ldap/lib/user/manager.php | 8 ++------
apps/user_ldap/user_ldap.php | 16 ++++++----------
3 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php
index a9d21ff..8cf954b 100644
--- a/apps/user_ldap/lib/connection.php
+++ b/apps/user_ldap/lib/connection.php
@@ -159,7 +159,8 @@ class Connection extends LDAPUtility {
$this->establishConnection();
}
if(is_null($this->ldapConnectionRes)) {
- \OCP\Util::writeLog('user_ldap', 'Connection could not be established', \OCP\Util::ERROR);
+ \OCP\Util::writeLog('user_ldap', 'No LDAP Connection to server ' . $this->connection->ldapHost, \OCP\Util::ERROR);
+ throw new \Exception('Connection to LDAP server could not be established');
}
return $this->ldapConnectionRes;
}
diff --git a/apps/user_ldap/lib/user/manager.php b/apps/user_ldap/lib/user/manager.php
index ec50e03..8a9a3b6 100644
--- a/apps/user_ldap/lib/user/manager.php
+++ b/apps/user_ldap/lib/user/manager.php
@@ -166,6 +166,7 @@ class Manager {
* @brief returns a User object by it's DN or ownCloud username
* @param string the DN or username of the user
* @return \OCA\user_ldap\lib\user\User|\OCA\user_ldap\lib\user\OfflineUser|null
+ * @throws \Exception when connection could not be established
*/
public function get($id) {
$this->checkAccess();
@@ -182,12 +183,7 @@ class Manager {
}
}
- try {
- $user = $this->createInstancyByUserName($id);
- return $user;
- } catch (\Exception $e) {
- return null;
- }
+ return $this->createInstancyByUserName($id);
}
}
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 051e760..c65c68d 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -188,6 +188,7 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
* check if a user exists
* @param string $uid the username
* @return boolean
+ * @throws \Exception when connection could not be established
*/
public function userExists($uid) {
if($this->access->connection->isCached('userExists'.$uid)) {
@@ -206,17 +207,12 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
return true;
}
- try {
- $result = $this->userExistsOnLDAP($user);
- $this->access->connection->writeToCache('userExists'.$uid, $result);
- if($result === true) {
- $user->update();
- }
- return $result;
- } catch (\Exception $e) {
- \OCP\Util::writeLog('user_ldap', $e->getMessage(), \OCP\Util::WARN);
- return false;
+ $result = $this->userExistsOnLDAP($user);
+ $this->access->connection->writeToCache('userExists'.$uid, $result);
+ if($result === true) {
+ $user->update();
}
+ return $result;
}
/**
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list