cvs: php-src /pear/PEAR ErrorStack.php
| From: | Greg Beaver | Date: | Tue, 27 Apr 2004 04:31:40 +0000 |
| Subject: | cvs: php-src /pear/PEAR ErrorStack.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-283@lists.php.net to get a copy of this message | ||
cellog Tue Apr 27 00:31:40 2004 EDT
Modified files:
/php-src/pear/PEAR ErrorStack.php
Log:
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
http://cvs.php.net/diff.php/php-src/pear/PEAR/ErrorStack.php?r1=1.2&r2=1.3&ty=u
Index: php-src/pear/PEAR/ErrorStack.php
diff -u php-src/pear/PEAR/ErrorStack.php:1.2 php-src/pear/PEAR/ErrorStack.php:1.3
--- php-src/pear/PEAR/ErrorStack.php:1.2 Sun Mar 21 18:00:54 2004
+++ php-src/pear/PEAR/ErrorStack.php Tue Apr 27 00:31:39 2004
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: ErrorStack.php,v 1.2 2004/03/21 23:00:54 cellog Exp $
+// $Id: ErrorStack.php,v 1.3 2004/04/27 04:31:39 cellog Exp $
/**
* Error Stack Implementation
@@ -664,12 +664,22 @@
}
/**
- * 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 @@
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 @@
$val = 'Object';
}
}
- $mainmsg = str_replace('%' . $name . '%', $val, $mainmsg);
+ $mainmsg = str_replace('%' . $name . '%', $val, $mainmsg);
}
}
return $mainmsg;