fix bug 1242 - notice if multi-dimensional array is passed as a parameter

add optional parameter to staticHasErrors() that allows error determination for a single package
This commit is contained in:
Greg Beaver 2004-04-27 04:31:39 +00:00
parent e744a448ab
commit 1f22d848e9

View file

@ -664,12 +664,22 @@ class PEAR_ErrorStack {
}
/**
* Determine whether there are any errors on any error stack
* Determine whether there are any errors on a single error stack, or on any error stack
*
* The optional parameter can be used to test the existence of any errors without the need of
* singleton instantiation
* @param string|false Package name to check for errors
* @return boolean
* @static
*/
function staticHasErrors()
function staticHasErrors($package = false)
{
if ($package) {
if (!isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
return false;
}
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->hasErrors();
}
foreach ($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] as $package => $obj) {
if ($obj->hasErrors()) {
return true;
@ -824,7 +834,8 @@ class PEAR_ErrorStack {
if (count($err['params'])) {
foreach ($err['params'] as $name => $val) {
if (is_array($val)) {
$val = implode(', ', $val);
// @ is needed in case $val is a multi-dimensional array
$val = @implode(', ', $val);
}
if (is_object($val)) {
if (method_exists($val, '__toString')) {