summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Beaver <cellog@php.net>2003-08-13 20:36:54 +0000
committerGreg Beaver <cellog@php.net>2003-08-13 20:36:54 +0000
commit0901d5e3b7032f4b5221feb08d3a0a482d1680c9 (patch)
tree5518a849edc7828d178afe6d1a1dfee66fa800b7
parent6366483f1bcb6090fe6fc19d6d0da83728d34375 (diff)
downloadphp-git-0901d5e3b7032f4b5221feb08d3a0a482d1680c9.tar.gz
fix for Bug #21845 $this in static calls
-rw-r--r--pear/PEAR.php44
1 files changed, 37 insertions, 7 deletions
diff --git a/pear/PEAR.php b/pear/PEAR.php
index ec98d5576f..7081547634 100644
--- a/pear/PEAR.php
+++ b/pear/PEAR.php
@@ -289,7 +289,8 @@ class PEAR
function setErrorHandling($mode = null, $options = null)
{
- if (isset($this)) {
+ if (isset($this) &&
+ (get_class($this) == 'pear' || is_subclass_of($this, 'pear'))) {
$setmode = &$this->_default_error_mode;
$setoptions = &$this->_default_error_options;
} else {
@@ -310,9 +311,35 @@ class PEAR
case PEAR_ERROR_CALLBACK:
$setmode = $mode;
- if ((is_string($options) && function_exists($options)) ||
- (is_array($options) && method_exists(@$options[0], @$options[1])))
- {
+ $doSet = false;
+ // function callback
+ if (is_string($options) && function_exists($options)) {
+ $doSet = true;
+ }
+ // class/object method callback
+ if (is_array($options)) {
+ if (isset($options[0]) && isset($options[1])) {
+ $options = array(&$options[0], $options[1]);
+ if (is_string($options[1])) {
+ // static method callback
+ if (is_string($options[0])) {
+ if (class_exists($options[0]) &&
+ in_array(strtolower($options[1]),
+ get_class_methods($options[0])))
+ {
+ $doSet = true;
+ }
+ }
+ // object method callback
+ if (is_object($options[0])) {
+ if (method_exists($options[0], $options[1])) {
+ $doSet = true;
+ }
+ }
+ }
+ }
+ }
+ if ($doSet) {
$setoptions = $options;
} else {
trigger_error("invalid error callback", E_USER_WARNING);
@@ -566,7 +593,8 @@ class PEAR
function pushErrorHandling($mode, $options = null)
{
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
- if (isset($this)) {
+ if (isset($this) &&
+ (get_class($this) == 'pear' || is_subclass_of($this, 'pear'))) {
$def_mode = &$this->_default_error_mode;
$def_options = &$this->_default_error_options;
} else {
@@ -575,7 +603,8 @@ class PEAR
}
$stack[] = array($def_mode, $def_options);
- if (isset($this)) {
+ if (isset($this) &&
+ (get_class($this) == 'pear' || is_subclass_of($this, 'pear'))) {
$this->setErrorHandling($mode, $options);
} else {
PEAR::setErrorHandling($mode, $options);
@@ -600,7 +629,8 @@ class PEAR
array_pop($stack);
list($mode, $options) = $stack[sizeof($stack) - 1];
array_pop($stack);
- if (isset($this)) {
+ if (isset($this) &&
+ (get_class($this) == 'pear' || is_subclass_of($this, 'pear'))) {
$this->setErrorHandling($mode, $options);
} else {
PEAR::setErrorHandling($mode, $options);