From: Michael M Slusarz Date: Mon, 8 Mar 2010 03:00:29 +0000 (-0700) Subject: Update Horde_Util::assertDriverConfig() to H4 standards X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=aae7974f117036bf7cd1abfb5296284a0a995f06;p=horde.git Update Horde_Util::assertDriverConfig() to H4 standards --- diff --git a/framework/Cache/lib/Horde/Cache/Sql.php b/framework/Cache/lib/Horde/Cache/Sql.php index 09efe860b..c14fc8ed6 100644 --- a/framework/Cache/lib/Horde/Cache/Sql.php +++ b/framework/Cache/lib/Horde/Cache/Sql.php @@ -350,10 +350,7 @@ class Horde_Cache_Sql extends Horde_Cache_Base return true; } - $result = Horde_Util::assertDriverConfig($this->_params, array('phptype'), 'cache SQL', array('driver' => 'cache')); - if (is_a($result, 'PEAR_Error')) { - throw new Horde_Exception($result->getMessage()); - } + Horde_Util::assertDriverConfig($this->_params, array('phptype'), 'cache SQL'); $this->_write_db = DB::connect( $this->_params, diff --git a/framework/Lock/lib/Horde/Lock/Sql.php b/framework/Lock/lib/Horde/Lock/Sql.php index efc7dd8c4..a83827844 100644 --- a/framework/Lock/lib/Horde/Lock/Sql.php +++ b/framework/Lock/lib/Horde/Lock/Sql.php @@ -321,14 +321,13 @@ class Horde_Lock_Sql extends Horde_Lock return true; } - $result = Horde_Util::assertDriverConfig($this->_params, array('phptype'), - 'Lock SQL', array('driver' => 'lock')); - if (is_a($result, 'PEAR_Error')) { - Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR); - throw new Horde_Lock_Exception($result->getMessage()); + try { + Horde_Util::assertDriverConfig($this->_params, array('phptype'), 'Lock SQL'); + } catch (Horde_Exception $e) { + Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR); + throw new Horde_Lock_Exception($e); } - require_once 'DB.php'; $this->_write_db = &DB::connect( $this->_params, array('persistent' => !empty($this->_params['persistent']), diff --git a/framework/Token/lib/Horde/Token/Sql.php b/framework/Token/lib/Horde/Token/Sql.php index cb30b3810..c77de0e7b 100644 --- a/framework/Token/lib/Horde/Token/Sql.php +++ b/framework/Token/lib/Horde/Token/Sql.php @@ -172,7 +172,7 @@ class Horde_Token_Sql extends Horde_Token return; } - Horde_Util::assertDriverConfig($this->_params, array('phptype'), 'token SQL', array('driver' => 'token')); + Horde_Util::assertDriverConfig($this->_params, array('phptype'), 'token SQL'); if (!isset($this->_params['database'])) { $this->_params['database'] = ''; diff --git a/framework/Util/lib/Horde/Util.php b/framework/Util/lib/Horde/Util.php index e5e9c2b4b..cccea4439 100644 --- a/framework/Util/lib/Horde/Util.php +++ b/framework/Util/lib/Horde/Util.php @@ -14,10 +14,10 @@ class Horde_Util { /* Error code for a missing driver configuration. */ - const HORDE_ERROR_DRIVER_CONFIG_MISSING = 1; + const DRIVER_CONFIG_MISSING = 1; /* Error code for an incomplete driver configuration. */ - const HORDE_ERROR_DRIVER_CONFIG = 2; + const DRIVER_CONFIG = 2; /** * A list of random patterns to use for overwriting purposes. @@ -727,19 +727,17 @@ class Horde_Util /** * Checks if all necessary parameters for a driver's configuration are set - * and returns a PEAR_Error if something is missing. + * and throws an exception if something is missing. * * @param array $params The configuration array with all parameters. * @param array $fields An array with mandatory parameter names for this * driver. * @param string $name The clear text name of the driver. If not * specified, the application name will be used. - * @param array $info A hash containing detailed information about the - * driver. Will be passed as the userInfo to the - * PEAR_Error. + * + * @throws Horde_Exception */ - static public function assertDriverConfig($params, $fields, $name, - $info = array()) + static public function assertDriverConfig($params, $fields, $name) { $info = array_merge($info, array( 'params' => $params, @@ -748,12 +746,12 @@ class Horde_Util )); if (!is_array($params) || !count($params)) { - return PEAR::throwError(sprintf(_("No configuration information specified for %s."), $name), self::HORDE_ERROR_DRIVER_CONFIG_MISSING, $info); + throw new Horde_Exception(sprintf('No configuration information specified for %s.', $name), self::DRIVER_CONFIG_MISSING); } foreach ($fields as $field) { if (!isset($params[$field])) { - return PEAR::throwError(sprintf(_("Required \"%s\" not specified in configuration."), $field, $name), self::HORDE_ERROR_DRIVER_CONFIG, $info); + throw new Horde_Exception(sprintf('Required "%s" not specified in configuration.', $field, $name), self::DRIVER_CONFIG); } } }