Permalink
Browse files

* Fix error handling

* Prevent a recursive loop when getting default values
* Fix preference deletion


git-svn-id: http://svn.php.net/repository/pear/packages/Auth_PrefManager2/trunk@162810 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent d4d7c29 commit 1fc4a8afd3fac16101c691c17cebf78b760547e9 Jon Wood committed Jul 7, 2004
Showing with 16 additions and 11 deletions.
  1. +16 −11 PrefManager2/Container.php
View
@@ -1,4 +1,5 @@
<?php
+require_once('Auth/PrefManager2.php');
class Auth_PrefManager2_Container {
@@ -31,7 +32,7 @@ class Auth_PrefManager2_Container {
* @return void
* @see Auth_PrefManager2::&factory()
*/
- function Auth_PrefManager2_Common($options = array())
+ function Auth_PrefManager2_Container($options = array())
{
$this->_errorStack =& PEAR_ErrorStack::singleton('Auth_PrefManager2');
$this->_parseOptions($options);
@@ -62,7 +63,7 @@ function getPref($preference, $owner = null, $application = null, $returnDefault
if (!is_null($value = $this->_get($owner, $preference, $application))) {
return $this->_decodeValue($value);
} else {
- if ($returnDefaults && $options['return_defaults']) {
+ if ($returnDefaults && $this->_options['return_defaults'] && ($owner != $this->_options['default_app'])) {
return $this->getPref($preference, null, $application);
}
}
@@ -112,7 +113,7 @@ function deletePref($preference, $owner = null, $application = null)
$application = $this->_options['default_app'];
}
- return $this->_delete($owner, $preference, $application = null);
+ return $this->_delete($owner, $preference, $application);
}
/**
@@ -239,8 +240,8 @@ function _decodeValue($value)
*/
function _parseOptions($options)
{
- if (!isset($options['default_user'])) {
- $options['default_user'] = 'default';
+ if (!isset($options['default_owner'])) {
+ $options['default_owner'] = 'default';
}
if (!isset($options['default_app'])) {
@@ -267,6 +268,10 @@ function _parseOptions($options)
$options['locale'] = 'en';
}
+ if (!isset($options['return_defaults'])) {
+ $options['return_defaults'] = true;
+ }
+
$this->_options = $options;
}
@@ -284,12 +289,12 @@ function _throwError($code, $level = 'error', $params = array(), $repackage = nu
$locale = isset($this->_errorMessages['_Auth_PrefManager2'][$this->_options['locale']])
? $this->_options['locale']
: 'en';
-
- $this->_errorStack->push($code,
- 'notice',
- array('name' => $name,
- 'value' => $value),
- $GLOBALS['_Auth_PrefManager2'][$locale][$code]);
+
+ var_dump($this->_errorStack->push($code,
+ $level,
+ $params,
+ $GLOBALS['_Auth_PrefManager2']['err'][$locale][$code],
+ $repackage));
}
}

0 comments on commit 1fc4a8a

Please sign in to comment.