summaryrefslogtreecommitdiff
path: root/pear
diff options
context:
space:
mode:
authorGreg Beaver <cellog@php.net>2004-04-27 04:31:39 +0000
committerGreg Beaver <cellog@php.net>2004-04-27 04:31:39 +0000
commit1f22d848e98e66939b8aa765892f9f9b8cd4034c (patch)
treeec390a1324508499906ae6f84bd8fab9baf9a754 /pear
parente744a448ab4c1ac83e20d4bbdf3508e063ca58ff (diff)
downloadphp-git-1f22d848e98e66939b8aa765892f9f9b8cd4034c.tar.gz
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
Diffstat (limited to 'pear')
-rw-r--r--pear/PEAR/ErrorStack.php19
1 files changed, 15 insertions, 4 deletions
diff --git a/pear/PEAR/ErrorStack.php b/pear/PEAR/ErrorStack.php
index f895835a8d..dd0ad68f46 100644
--- a/pear/PEAR/ErrorStack.php
+++ b/pear/PEAR/ErrorStack.php
@@ -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')) {
@@ -836,7 +847,7 @@ class PEAR_ErrorStack {
$val = 'Object';
}
}
- $mainmsg = str_replace('%' . $name . '%', $val, $mainmsg);
+ $mainmsg = str_replace('%' . $name . '%', $val, $mainmsg);
}
}
return $mainmsg;