don't catch exceptions and throw them away unless we are really, really sure we want...
authorChuck Hagenbuch <chuck@horde.org>
Tue, 14 Jul 2009 04:30:46 +0000 (00:30 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Tue, 14 Jul 2009 04:30:46 +0000 (00:30 -0400)
framework/Auth/lib/Horde/Auth.php
framework/Auth/lib/Horde/Auth/Driver.php
framework/Auth/lib/Horde/Auth/Msad.php
framework/Auth/lib/Horde/Auth/Signup.php
framework/Core/lib/Horde/Registry.php

index 976ab29..91bb640 100644 (file)
@@ -512,14 +512,12 @@ class Horde_Auth
         $userId = self::addHook(trim($userId));
 
         if (!empty($GLOBALS['conf']['hooks']['postauthenticate'])) {
-            try {
-                if (!Horde::callHook('_horde_hook_postauthenticate', array($userId, $credentials, $realm), 'horde')) {
-                    if (self::getAuthError() != self::REASON_MESSAGE) {
-                        self::setAuthError(self::REASON_FAILED);
-                    }
-                    return false;
+            if (Horde::callHook('_horde_hook_postauthenticate', array($userId, $credentials, $realm), 'horde') === false) {
+                if (self::getAuthError() != self::REASON_MESSAGE) {
+                    self::setAuthError(self::REASON_FAILED);
                 }
-            } catch (Horde_Exception $e) {}
+                return false;
+            }
         }
 
         /* If we're already set with this userId, don't continue. */
@@ -578,14 +576,14 @@ class Horde_Auth
             : $_SERVER['HTTP_X_FORWARDED_FOR'];
 
         if (class_exists('Net_DNS')) {
-           $resolver = new Net_DNS_Resolver();
-           $resolver->retry = isset($GLOBALS['conf']['dns']['retry']) ? $GLOBALS['conf']['dns']['retry'] : 1;
-           $resolver->retrans = isset($GLOBALS['conf']['dns']['retrans']) ? $GLOBALS['conf']['dns']['retrans'] : 1;
-           $response = $resolver->query($host, 'PTR');
-           $ptrdname = $response ? $response->answer[0]->ptrdname : $host;
-       } else {
-           $ptrdname = @gethostbyaddr($host);
-       }
+            $resolver = new Net_DNS_Resolver();
+            $resolver->retry = isset($GLOBALS['conf']['dns']['retry']) ? $GLOBALS['conf']['dns']['retry'] : 1;
+            $resolver->retrans = isset($GLOBALS['conf']['dns']['retrans']) ? $GLOBALS['conf']['dns']['retrans'] : 1;
+            $response = $resolver->query($host, 'PTR');
+            $ptrdname = $response ? $response->answer[0]->ptrdname : $host;
+        } else {
+            $ptrdname = @gethostbyaddr($host);
+        }
 
         $last_login = array('time' => time(), 'host' => $ptrdname);
         $GLOBALS['prefs']->setValue('last_login', serialize($last_login));
@@ -688,7 +686,6 @@ class Horde_Auth
      * @param string $userId  The authentication backend's user name.
      *
      * @return string  The internal Horde user name.
-     * @throws Horde_Exception
      */
     static public function addHook($userId)
     {
@@ -709,7 +706,6 @@ class Horde_Auth
      * @param string $userId  The internal Horde user name.
      *
      * @return string  The authentication backend's user name.
-     * @throws Horde_Exception
      */
     static public function removeHook($userId)
     {
index e1e70e5..7583bcb 100644 (file)
@@ -74,14 +74,12 @@ class Horde_Auth_Driver
         $userId = trim($userId);
 
         if (!empty($GLOBALS['conf']['hooks']['preauthenticate'])) {
-            try {
-                if (!Horde::callHook('_horde_hook_preauthenticate', array($userId, $credentials, $realm), 'horde')) {
-                    if (Horde_Auth::getAuthError() != Horde_Auth::REASON_MESSAGE) {
-                        Horde_Auth::setAuthError(Horde_Auth::REASON_FAILED);
-                    }
-                    return false;
+            if (!Horde::callHook('_horde_hook_preauthenticate', array($userId, $credentials, $realm), 'horde')) {
+                if (Horde_Auth::getAuthError() != Horde_Auth::REASON_MESSAGE) {
+                    Horde_Auth::setAuthError(Horde_Auth::REASON_FAILED);
                 }
-            } catch (Horde_Exception $e) {}
+                return false;
+            }
         }
 
         /* Store the credentials being checked so that subclasses can modify
index 93d94f9..f46a5ea 100644 (file)
@@ -76,10 +76,7 @@ class Horde_Auth_Msad extends Horde_Auth_Ldap
         /* Connect to the MSAD server. */
         $this->_connect();
 
-        try {
-            $entry = Horde::callHook('_horde_hook_authmsad', array($accountName, $credentials), 'horde');
-        } catch (Horde_Exception $e) {}
-
+        $entry = Horde::callHook('_horde_hook_authmsad', array($accountName, $credentials), 'horde');
         if (!is_null($entry)) {
             $dn = $entry['dn'];
             unset($entry['dn']);
@@ -135,10 +132,7 @@ class Horde_Auth_Msad extends Horde_Auth_Ldap
         /* Connect to the MSAD server. */
         $this->_connect();
 
-        try {
-            $entry = Horde::callHook('_horde_hook_authmsad', array($accountName), 'horde');
-        } catch (Horde_Exception $e) {}
-
+        $entry = Horde::callHook('_horde_hook_authmsad', array($accountName), 'horde');
         $dn = is_null($entry)
             /* Search for the user's full DN. */
             ? $this->_findDN($accountName)
@@ -167,10 +161,7 @@ class Horde_Auth_Msad extends Horde_Auth_Ldap
         /* Connect to the MSAD server. */
         $this->_connect();
 
-        try {
-            $entry = Horde::callHook('_horde_hook_authmsad', array($oldId, $credentials), 'horde');
-        } catch (Horde_Exception $e) {}
-
+        $entry = Horde::callHook('_horde_hook_authmsad', array($oldId, $credentials), 'horde');
         if (!is_null($entry)) {
             $olddn = $entry['dn'];
             unset($entry['dn']);
index bcf3b05..36bd7aa 100644 (file)
@@ -115,9 +115,7 @@ class Horde_Auth_Signup
 
         // Perform any preprocessing if requested.
         if ($conf['signup']['preprocess']) {
-            try {
-                $info = Horde::callHook('_horde_hook_signup_preprocess', array($info));
-            } catch (Horde_Exception $e) {}
+            $info = Horde::callHook('_horde_hook_signup_preprocess', array($info));
         }
 
         // Check to see if the username already exists.
@@ -143,9 +141,7 @@ class Horde_Auth_Signup
         }
 
         if ($conf['signup']['queue']) {
-            try {
-                $result = Horde::callHook('_horde_hook_signup_queued', array($info['user_name'], $info));
-            } catch (Horde_Exception $e) {}
+            $result = Horde::callHook('_horde_hook_signup_queued', array($info['user_name'], $info));
         }
 
         if (!empty($conf['signup']['email'])) {
@@ -254,10 +250,7 @@ class HordeSignupForm extends Horde_Form {
         $this->addHidden('', 'url', 'text', false);
 
         /* Use hooks get any extra fields required in signing up. */
-        try {
-            $extra = Horde::callHook('_horde_hook_signup_getextra');
-        } catch (Horde_Exception $e) {}
-
+        $extra = Horde::callHook('_horde_hook_signup_getextra');
         if (!empty($extra)) {
             if (!isset($extra['user_name'])) {
                 $this->addVariable(_("Choose a username"), 'user_name', 'text', true);
index 094a343..34caabc 100644 (file)
@@ -159,7 +159,9 @@ class Horde_Registry
         if (Horde_Auth::getAuth()) {
             try {
                 $this->_cacheob = Horde_Cache::singleton($conf['cache']['driver'], Horde::getDriverConfig('cache', $conf['cache']['driver']));
-            } catch (Horde_Exception $e) {}
+            } catch (Horde_Exception $e) {
+                // @TODO Log error
+            }
         }
 
         $this->_regmtime = max(filemtime(HORDE_BASE . '/config/registry.php'),
@@ -819,9 +821,7 @@ class Horde_Registry
         $this->_appStack[] = $app;
 
         /* Call post-push hook. */
-        try {
-            Horde::callHook('_horde_hook_post_pushapp', array($app), 'horde');
-        } catch (Horde_Exception $e) {}
+        Horde::callHook('_horde_hook_post_pushapp', array($app), 'horde');
 
         return true;
     }