cvs: pear-core(PEAR_1_3) / PEAR.php
| From: | Greg Beaver | Date: | Tue, 19 Oct 2004 04:05:37 +0000 |
| Subject: | cvs: pear-core(PEAR_1_3) / PEAR.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-1058@lists.php.net to get a copy of this message | ||
cellog Tue Oct 19 00:05:37 2004 EDT
Modified files: (Branch: PEAR_1_3)
/pear-core PEAR.php
Log:
MFH all fixes
http://cvs.php.net/diff.php/pear-core/PEAR.php?r1=1.82&r2=1.82.2.1&ty=u
Index: pear-core/PEAR.php
diff -u pear-core/PEAR.php:1.82 pear-core/PEAR.php:1.82.2.1
--- pear-core/PEAR.php:1.82 Wed Jun 16 12:26:12 2004
+++ pear-core/PEAR.php Tue Oct 19 00:05:36 2004
@@ -18,7 +18,7 @@
// | Tomas V.V.Cox <cox@idecnet.com> |
// +--------------------------------------------------------------------+
//
-// $Id: PEAR.php,v 1.82 2004/06/16 16:26:12 ssb Exp $
+// $Id: PEAR.php,v 1.82.2.1 2004/10/19 04:05:36 cellog Exp $
//
define('PEAR_ERROR_RETURN', 1);
@@ -152,7 +152,7 @@
*/
function PEAR($error_class = null)
{
- $classname = get_class($this);
+ $classname = strtolower(get_class($this));
if ($this->_debug) {
print "PEAR constructor called, class=$classname\n";
}
@@ -164,6 +164,11 @@
if (method_exists($this, $destructor)) {
global $_PEAR_destructor_object_list;
$_PEAR_destructor_object_list[] = &$this;
+ static $registered = false;
+ if (!$registered) {
+ register_shutdown_function("_PEAR_call_destructors");
+ $registered = true;
+ }
break;
} else {
$classname = get_parent_class($classname);
@@ -187,7 +192,7 @@
*/
function _PEAR() {
if ($this->_debug) {
- printf("PEAR destructor called, class=%s\n", get_class($this));
+ printf("PEAR destructor called, class=%s\n", strtolower(get_class($this)));
}
}
@@ -561,6 +566,75 @@
}
// }}}
+ function staticPushErrorHandling($mode, $options = null)
+ {
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
+ $def_mode = &$GLOBALS['_PEAR_default_error_mode'];
+ $def_options = &$GLOBALS['_PEAR_default_error_options'];
+ $stack[] = array($def_mode, $def_options);
+ switch ($mode) {
+ case PEAR_ERROR_EXCEPTION:
+ case PEAR_ERROR_RETURN:
+ case PEAR_ERROR_PRINT:
+ case PEAR_ERROR_TRIGGER:
+ case PEAR_ERROR_DIE:
+ case null:
+ $def_mode = $mode;
+ $def_options = $options;
+ break;
+
+ case PEAR_ERROR_CALLBACK:
+ $def_mode = $mode;
+ // class/object method callback
+ if (is_callable($options)) {
+ $def_options = $options;
+ } else {
+ trigger_error("invalid error callback", E_USER_WARNING);
+ }
+ break;
+
+ default:
+ trigger_error("invalid error mode", E_USER_WARNING);
+ break;
+ }
+ $stack[] = array($mode, $options);
+ return true;
+ }
+
+ function staticPopErrorHandling()
+ {
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
+ array_pop($stack);
+ list($mode, $options) = $stack[sizeof($stack) - 1];
+ array_pop($stack);
+ switch ($mode) {
+ case PEAR_ERROR_EXCEPTION:
+ case PEAR_ERROR_RETURN:
+ case PEAR_ERROR_PRINT:
+ case PEAR_ERROR_TRIGGER:
+ case PEAR_ERROR_DIE:
+ case null:
+ $setmode = $mode;
+ $setoptions = $options;
+ break;
+
+ case PEAR_ERROR_CALLBACK:
+ $setmode = $mode;
+ // class/object method callback
+ if (is_callable($options)) {
+ $setoptions = $options;
+ } else {
+ trigger_error("invalid error callback", E_USER_WARNING);
+ }
+ break;
+
+ default:
+ trigger_error("invalid error mode", E_USER_WARNING);
+ break;
+ }
+ return true;
+ }
+
// {{{ pushErrorHandling()
/**
@@ -929,14 +1003,16 @@
E_USER_ERROR => 'error');
if ($this->mode & PEAR_ERROR_CALLBACK) {
if (is_array($this->callback)) {
- $callback = get_class($this->callback[0]) . '::' .
+ $callback = (is_object($this->callback[0]) ?
+ strtolower(get_class($this->callback[0])) :
+ $this->callback[0]) . '::' .
$this->callback[1];
} else {
$callback = $this->callback;
}
return sprintf('[%s: message="%s" code=%d mode=callback '.
'callback=%s prefix="%s" info="%s"]',
- get_class($this), $this->message, $this->code,
+ strtolower(get_class($this)), $this->message, $this->code,
$callback, $this->error_message_prefix,
$this->userinfo);
}
@@ -954,7 +1030,7 @@
}
return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
'prefix="%s" info="%s"]',
- get_class($this), $this->message, $this->code,
+ strtolower(get_class($this)), $this->message, $this->code,
implode("|", $modes), $levels[$this->level],
$this->error_message_prefix,
$this->userinfo);
@@ -963,8 +1039,6 @@
// }}}
}
-register_shutdown_function("_PEAR_call_destructors");
-
/*
* Local Variables:
* mode: php