25 define(
'PEAR_ERROR_RETURN', 1);
26 define(
'PEAR_ERROR_PRINT', 2);
27 define(
'PEAR_ERROR_TRIGGER', 4);
28 define(
'PEAR_ERROR_DIE', 8);
29 define(
'PEAR_ERROR_CALLBACK', 16);
34 define(
'PEAR_ERROR_EXCEPTION', 32);
36 define(
'PEAR_ZE2', (function_exists(
'version_compare') &&
37 version_compare(zend_version(),
"2-dev",
"ge")));
39 if (substr(PHP_OS, 0, 3) ==
'WIN') {
40 define(
'OS_WINDOWS',
true);
41 define(
'OS_UNIX',
false);
42 define(
'PEAR_OS',
'Windows');
44 define(
'OS_WINDOWS',
false);
45 define(
'OS_UNIX',
true);
46 define(
'PEAR_OS',
'Unix');
50 $GLOBALS[
'_PEAR_default_error_options'] = E_USER_NOTICE;
51 $GLOBALS[
'_PEAR_destructor_object_list'] = array();
53 $GLOBALS[
'_PEAR_error_handler_stack'] = array();
55 @ini_set(
'track_errors',
true);
149 function PEAR($error_class = null)
151 $classname = strtolower(get_class($this));
153 print
"PEAR constructor called, class=$classname\n";
156 if ($error_class !== null) {
157 $this->_error_class = $error_class;
160 while ($classname && strcasecmp($classname,
"pear")) {
161 $destructor =
"_$classname";
162 if (method_exists($this, $destructor)) {
163 global $_PEAR_destructor_object_list;
164 $_PEAR_destructor_object_list[] = &$this;
165 if (!isset(
$GLOBALS[
'_PEAR_SHUTDOWN_REGISTERED'])) {
166 register_shutdown_function(
"_PEAR_call_destructors");
167 $GLOBALS[
'_PEAR_SHUTDOWN_REGISTERED'] =
true;
171 $classname = get_parent_class($classname);
189 printf(
"PEAR destructor called, class=%s\n", strtolower(get_class($this)));
208 if (!isset($properties[$class])) {
209 $properties[$class] = array();
212 if (!array_key_exists($var, $properties[$class])) {
213 $properties[$class][$var] = null;
216 return $properties[$class][$var];
232 if (!isset(
$GLOBALS[
'_PEAR_SHUTDOWN_REGISTERED'])) {
233 register_shutdown_function(
"_PEAR_call_destructors");
234 $GLOBALS[
'_PEAR_SHUTDOWN_REGISTERED'] =
true;
252 if (!is_a($data,
'PEAR_Error')) {
256 if (is_null($code)) {
258 } elseif (is_string($code)) {
259 return $data->getMessage() == $code;
262 return $data->getCode() == $code;
305 if (isset($this) && is_a($this,
'PEAR')) {
309 $setmode = &
$GLOBALS[
'_PEAR_default_error_mode'];
310 $setoptions = &
$GLOBALS[
'_PEAR_default_error_options'];
321 $setoptions = $options;
327 if (is_callable($options)) {
328 $setoptions = $options;
330 trigger_error(
"invalid error callback", E_USER_WARNING);
335 trigger_error(
"invalid error mode", E_USER_WARNING);
357 if (is_array($code)) {
358 array_push($this->_expected_errors, $code);
360 array_push($this->_expected_errors, array($code));
362 return count($this->_expected_errors);
373 return array_pop($this->_expected_errors);
387 foreach ($this->_expected_errors as $key => $error_array) {
388 if (in_array($error_code, $error_array)) {
389 unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
394 if (0 == count($this->_expected_errors[$key])) {
395 unset($this->_expected_errors[$key]);
414 if ((is_array($error_code) && (0 != count($error_code)))) {
417 foreach ($error_code as $key => $error) {
421 return $deleted ?
true :
PEAR::raiseError(
"The expected error you submitted does not exist");
422 } elseif (!empty($error_code)) {
481 if (is_object($message)) {
482 $code = $message->getCode();
483 $userinfo = $message->getUserInfo();
484 $error_class = $message->getType();
485 $message->error_message_prefix =
'';
486 $message = $message->getMessage();
491 isset($this->_expected_errors) &&
492 count($this->_expected_errors) > 0 &&
493 count($exp = end($this->_expected_errors))
495 if ($exp[0] ==
"*" ||
496 (is_int(reset($exp)) && in_array($code, $exp)) ||
497 (is_string(reset($exp)) && in_array($message, $exp))
504 if ($mode === null) {
506 if (isset($this) && isset($this->_default_error_mode)) {
510 } elseif (isset(
$GLOBALS[
'_PEAR_default_error_mode'])) {
511 $mode =
$GLOBALS[
'_PEAR_default_error_mode'];
512 $options =
$GLOBALS[
'_PEAR_default_error_options'];
516 if ($error_class !== null) {
518 } elseif (isset($this) && isset($this->_error_class)) {
524 if (intval(PHP_VERSION) < 5) {
526 include
'PEAR/FixPHP5PEARWarnings.php';
531 $a =
new $ec($code, $mode, $options, $userinfo);
533 $a =
new $ec($message, $code, $mode, $options, $userinfo);
555 function &
throwError($message = null, $code = null, $userinfo = null)
557 if (isset($this) && is_a($this,
'PEAR')) {
558 $a = &$this->
raiseError($message, $code, null, null, $userinfo);
568 $stack = &
$GLOBALS[
'_PEAR_error_handler_stack'];
569 $def_mode = &
$GLOBALS[
'_PEAR_default_error_mode'];
570 $def_options = &
$GLOBALS[
'_PEAR_default_error_options'];
571 $stack[] = array($def_mode, $def_options);
580 $def_options = $options;
586 if (is_callable($options)) {
587 $def_options = $options;
589 trigger_error(
"invalid error callback", E_USER_WARNING);
594 trigger_error(
"invalid error mode", E_USER_WARNING);
597 $stack[] = array($mode, $options);
603 $stack = &
$GLOBALS[
'_PEAR_error_handler_stack'];
604 $setmode = &
$GLOBALS[
'_PEAR_default_error_mode'];
605 $setoptions = &
$GLOBALS[
'_PEAR_default_error_options'];
607 list($mode, $options) = $stack[
sizeof($stack) - 1];
617 $setoptions = $options;
623 if (is_callable($options)) {
624 $setoptions = $options;
626 trigger_error(
"invalid error callback", E_USER_WARNING);
631 trigger_error(
"invalid error mode", E_USER_WARNING);
651 $stack = &
$GLOBALS[
'_PEAR_error_handler_stack'];
652 if (isset($this) && is_a($this,
'PEAR')) {
656 $def_mode = &
$GLOBALS[
'_PEAR_default_error_mode'];
657 $def_options = &
$GLOBALS[
'_PEAR_default_error_options'];
659 $stack[] = array($def_mode, $def_options);
661 if (isset($this) && is_a($this,
'PEAR')) {
666 $stack[] = array($mode, $options);
679 $stack = &
$GLOBALS[
'_PEAR_error_handler_stack'];
681 list($mode, $options) = $stack[
sizeof($stack) - 1];
683 if (isset($this) && is_a($this,
'PEAR')) {
700 if (extension_loaded($ext)) {
706 function_exists(
'dl') ===
false ||
707 ini_get(
'enable_dl') != 1 ||
708 ini_get(
'safe_mode') == 1
715 } elseif (PHP_OS ==
'HP-UX') {
717 } elseif (PHP_OS ==
'AIX') {
719 } elseif (PHP_OS ==
'OSX') {
725 return @dl(
'php_'.$ext.$suffix) || @dl($ext.$suffix);
730 include_once
'PEAR5.php';
735 global $_PEAR_destructor_object_list;
736 if (is_array($_PEAR_destructor_object_list) &&
737 sizeof($_PEAR_destructor_object_list))
739 reset($_PEAR_destructor_object_list);
746 if ($destructLifoExists) {
747 $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
750 while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
751 $classname = get_class($objref);
753 $destructor =
"_$classname";
754 if (method_exists($objref, $destructor)) {
755 $objref->$destructor();
758 $classname = get_parent_class($classname);
764 $_PEAR_destructor_object_list = array();
769 isset(
$GLOBALS[
'_PEAR_shutdown_funcs']) &&
770 is_array(
$GLOBALS[
'_PEAR_shutdown_funcs']) &&
771 !empty(
$GLOBALS[
'_PEAR_shutdown_funcs'])
773 foreach (
$GLOBALS[
'_PEAR_shutdown_funcs'] as $value) {
774 call_user_func_array($value[0], $value[1]);
829 if (
$mode === null) {
844 $this->backtrace = debug_backtrace();
845 if (isset($this->backtrace[0]) && isset($this->backtrace[0][
'object'])) {
846 unset($this->backtrace[0][
'object']);
851 $this->level = E_USER_NOTICE;
852 $this->callback = $options;
854 if ($options === null) {
855 $options = E_USER_NOTICE;
858 $this->level = $options;
859 $this->callback = null;
863 if (is_null($options) || is_int($options)) {
873 trigger_error($this->
getMessage(), $this->level);
878 if (is_null($options) || is_int($options)) {
880 if (substr($msg, -1) !=
"\n") {
886 die(sprintf($format, $msg));
889 if ($this->mode & PEAR_ERROR_CALLBACK && is_callable($this->callback)) {
890 call_user_func($this->callback, $this);
894 trigger_error(
"PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING);
895 eval(
'$e = new Exception($this->message, $this->code);throw($e);');
918 return $this->callback;
929 return ($this->error_message_prefix . $this->
message);
951 return get_class($this);
986 if (defined(
'PEAR_IGNORE_BACKTRACE')) {
989 if ($frame === null) {
992 return $this->backtrace[$frame];
997 if (empty($this->userinfo)) {
998 $this->userinfo = $info;
1000 $this->userinfo .=
" ** $info";
1018 $levels = array(E_USER_NOTICE =>
'notice',
1019 E_USER_WARNING =>
'warning',
1020 E_USER_ERROR =>
'error');
1022 if (is_array($this->callback)) {
1023 $callback = (is_object($this->callback[0]) ?
1024 strtolower(get_class($this->callback[0])) :
1025 $this->callback[0]) .
'::' .
1028 $callback = $this->callback;
1030 return sprintf(
'[%s: message="%s" code=%d mode=callback '.
1031 'callback=%s prefix="%s" info="%s"]',
1032 strtolower(get_class($this)), $this->
message, $this->code,
1033 $callback, $this->error_message_prefix,
1040 $modes[] =
'trigger';
1046 $modes[] =
'return';
1048 return sprintf(
'[%s: message="%s" code=%d mode=%s level=%s '.
1049 'prefix="%s" info="%s"]',
1050 strtolower(get_class($this)), $this->
message, $this->code,
1051 implode(
"|", $modes), $levels[$this->level],
1052 $this->error_message_prefix,
registerShutdownFunc($func, $args=array())
static & getStaticProperty($class, $var)
setErrorHandling($mode=null, $options=null)
const PEAR_ERROR_CALLBACK
if(file_exists(_XE_PATH_. 'config/config.user.inc.php')) if(!defined('__DEBUG__')) if(!defined('__DEBUG_OUTPUT__')) if(!defined('__DEBUG_PROTECT__')) if(!defined('__DEBUG_PROTECT_IP__')) if(!defined('__DEBUG_DB_OUTPUT__')) if(!defined('__LOG_SLOW_QUERY__')) if(!defined('__LOG_SLOW_TRIGGER__')) if(!defined('__LOG_SLOW_ADDON__')) if(!defined('__LOG_SLOW_WIDGET__')) if(!defined('__DEBUG_QUERY__')) if(!defined('__OB_GZHANDLER_ENABLE__')) if(!defined('__ENABLE_PHPUNIT_TEST__')) if(!defined('__PROXY_SERVER__')) if(!defined('__ERROR_LOG__')) if(!defined('__DISABLE_DEFAULT_CSS__')) if(!defined('__AUTO_OPCACHE_INVALIDATE__')) if((__DEBUG_OUTPUT__==2)&&version_compare(PHP_VERSION, '6.0.0')===-1) if(version_compare(PHP_VERSION, '5.3.0') >=0) $GLOBALS['__xe_autoload_file_map']
_checkDelExpect($error_code)
PEAR_Error($message= 'unknown error', $code=null, $mode=null, $options=null, $userinfo=null)
high class of message module
getBacktrace($frame=null)
& throwError($message=null, $code=null, $userinfo=null)
const PEAR_ERROR_EXCEPTION
if(PEAR_ZE2) _PEAR_call_destructors()
pushErrorHandling($mode, $options=null)
& raiseError($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
staticPushErrorHandling($mode, $options=null)
isError($data, $code=null)
& getStaticProperty($class, $var)