ID: 25128
Updated by: [EMAIL PROTECTED]
Reported By: auroraeosrose at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: *General Issues
Operating System: Win XP Pro SP1
PHP Version: 4CVS-2003-08-18 (stable)
New Comment:
Just move the set_error_handler() outside the class.
(after you init the object)
Previous Comments:
------------------------------------------------------------------------
[2003-08-18 10:21:19] auroraeosrose at hotmail dot com
BTW if this is the desired behavior, that you can't manipulate an error
handler class after assigning it, that should be in BIG BOLD LETTERS in
the documentation
------------------------------------------------------------------------
[2003-08-18 10:04:25] auroraeosrose at hotmail dot com
You're missing the point, I want to send a referenced object and be
able to change things it before I trigger an error...another test
<?
class Stack
{
var $stack;
var $debug;
function Stack()
{
$this->stack = array();
$this->debug = false;
set_error_handler(array(&$this, 'errorHandler'));
}
function push($message)
{
$this->stack[] = $message;
print_r($this); //for debugging
}
function errorHandler($code, $message, $file, $line, $context)
{
$this->push($message);
}
}
$e = new Stack();
$e->debug = true;
trigger_error('This is a test', E_USER_NOTICE);
?>
Now, notice I've changed debug before I triggered the error, so when I
do my print_r of $this it should have debug set to true, because I
changed it, but notice it's still set to false
------------------------------------------------------------------------
[2003-08-18 09:37:21] [EMAIL PROTECTED]
If you use the trigger_error() twice, it'll push the messages into the
array just fine. Not bug.
------------------------------------------------------------------------
[2003-08-18 09:22:26] auroraeosrose at hotmail dot com
Description:
------------
Latest cvs snapshot of 4.3.whatever we're at now. When sending an
object/method array for a set_error_handler, the object is not being
referenced, I have no idea what it's doing.
I'd like to be able to change stuff in the object I have the error
handler in before an error is triggered...
This may be a dupe of #22894 but I'm not sure since that one wasn't
explained very well...
Reproduce code:
---------------
<?
class Stack
{
var $stack;
function Stack()
{
$this->stack = array();
set_error_handler(array(&$this, 'errorHandler'));
}
function push($message)
{
$this->stack[] = $message;
print_r($this); //for debugging
}
function errorHandler($code, $message, $file, $line, $context)
{
$this->push($message);
}
}
$e = new Stack();
$e->push('This is a fun test');
trigger_error('This is a test', E_USER_NOTICE);
?>
Expected result:
----------------
stack Object
(
[stack] => Array
(
[0] => This is a fun test
)
)
stack Object
(
[stack] => Array
(
[0] => This is fun a test
[1] => This is a test
)
)
Actual result:
--------------
stack Object
(
[stack] => Array
(
[0] => This is a fun test
)
)
stack Object
(
[stack] => Array
(
[0] => This is a test
)
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25128&edit=1