Ask a Question related to PHP Development, Design and Development.
-
sniper@php.net #1
#25580 [WFx]: set_error_handler to a class/method resets class properties when error occurs
ID: 25580
Updated by: [email]sniper@php.net[/email]
Reported By: paul dot liversidge at recycledpixels dot com
Status: Wont fix
Bug Type: Class/Object related
Operating System: Windows XP
PHP Version: 4.3.2
New Comment:
And this would make it work as you expect too:
$err =& new ErrorHandler;
Previous Comments:
------------------------------------------------------------------------
[2003-09-20 18:12:59] [email]sniper@php.net[/email]
Fixed in PHP 5, won't fix in PHP 4.
See also: [url]http://fi.php.net/manual/en/language.oop.newref.php[/url]
------------------------------------------------------------------------
[2003-09-17 16:05:02] paul dot liversidge at recycledpixels dot com
If I add a new method to the class, activate (see below), remove the
constructor method and call this new function immediately after
instantiating the class, i.e. $err->activate (); it all works fine as
well.
function activate () {
$this->old_error_handler = set_error_handler (array (&$this,
'handle_error'));
}
It seems to be something related to setting the error handler in the
constructor method.
------------------------------------------------------------------------
[2003-09-17 15:28:50] paul dot liversidge at recycledpixels dot com
Description:
------------
I set the error handler to point at a class/method and then change some
of the class variables. Debugging lines and method confirm the class
variable has occurred. When I then trigger an error by echo'ing an
uninitialized variable the error handler resets or reinstantiates the
class.
If $use_me is initialized in the constructor instead of being defined
as a 'constant', it makes no difference as the value at the time of an
error is NULL, whatever is defined in the core class code.
If the set_error_handler function is called from line 3, i.e.
set_error_handler (array (&$err, 'handler_error')), it all works fine.
Reproduce code:
---------------
<?
$err = new ErrorHandler;
$err->use_me = true;
echo ("[1:{$err->use_me}]");
$err->test ();
echo $fred;
class ErrorHandler {
var $use_me = 4;
function ErrorHandler () {
set_error_handler (array (&$this, 'handle_error'));
}
function test () {
echo ("[2:{$this->use_me}]");
}
function handle_error ($number, $message, $file, $line, $context) {
echo ("[3:{$this->use_me}]");
echo ("Error $number");
}
}
?>
Expected result:
----------------
[1:1][2:1][3:1]Error 8
Actual result:
--------------
[1:1][2:1][3:4]Error 8
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=25580&edit=1[/url]
sniper@php.net Guest
-
Error occuring when i execute Fire method of BaseEvent Class
I am getting following error when i am executing Fire() method of BaseEvent Class System.Exception: This schema for this assembly has not been... -
#25908 [Bgs]: Inherited class properties aren't inherited until after class is parsed [?]
ID: 25908 Updated by: helly@php.net Reported By: kyle at putnamcabinets dot com Status: Bogus Bug Type: ... -
#25580 [Opn->WFx]: set_error_handler to a class/method resets class properties when error occurs
ID: 25580 Updated by: sniper@php.net Reported By: paul dot liversidge at recycledpixels dot com -Status: Open... -
#25580 [Opn]: set_error_handler to a class/method resets class properties when error occurs
ID: 25580 User updated by: paul.liversidge@recycledpixels.com Reported By: paul dot liversidge at recycledpixels dot com... -
#25580 [NEW]: set_error_handler to a class/method resets class properties when error occurs
From: paul dot liversidge at recycledpixels dot com Operating system: Windows XP PHP version: 4.3.2 PHP Bug Type: ...



Reply With Quote

