Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.9

Bug #17398 Error: PEAR::setErrorHandling(PEAR_ERROR_EXCEPTION);
Submitted: 2010-05-13 21:46 UTC
From: walkinraven Assigned:
Status: Bogus Package: PEAR (version Unknown)
PHP Version: 5.2.4 OS: Ubuntu 8.04
Roadmaps: (Not assigned)    
Subscription  


 [2010-05-13 21:46 UTC] walkinraven (Winfred Qin)
Description: ------------ You will get error message 'Assigning the return value of new by reference is deprecated', if you code as below: 1.Define two user-defined error handler functions for 'set_error_handler' and 'set_exception_handler', globally; 2.Define a class for initializing the PHP environment, named 'PHP_Initializer' for example; 3.In ' PHP_Initializer::__construct', call 'set_error_handler', 'set_exception_handler' and 'PEAR::setErrorHandling(PEAR_ERROR_EXCEPTION);' 4.You will get error message: 'Assigning the return value of new by reference is deprecated' Test script: --------------- URL ( 35 lines ): http://docs.google.com/View?id=dgt79v8r_119cf9hrvdj Expected result: ---------------- I don't think an error should be produced with my code. Actual result: -------------- Error message: 'Assigning the return value of new by reference is deprecated'

Comments

 [2010-05-14 02:33 UTC] dufuz (Helgi Þormar Þorbjörnsson)
-Status: Open +Status: Bogus
Thank you for submitting this ticket but it is not a bug. It is a deprecation warning which is present on PHP 5 while the PEAR installer (e.g. the PEAR class) is PHP 4 compatible, and this deprecation warning can only be removed if we break backwards compatibility for PHP 4, which would not sit well with many companies. As it's only an warning then you can safely ignore it.
 [2010-05-14 07:29 UTC] walkinraven (Winfred Qin)
Thank you for replying, I understand PHP 4 compatibility is more important thing. Then I have to solve the problem by adding a if statement in my user-defined error handler function: the code: function exception_error_handler($errno, $errstr, $errfile, $errline ) { if ( $errstr==='Assigning the return value of new by reference is deprecated') { return; } throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } But I have some worried about that: Does this error message is unique? Whether the code above will ignore some other error that should be dealt with? If I put $errfile/$errline into the if statement, then when the source file changed, it could be a big trouble to trace the if statement. A better way may be: if ( $errno<x ) { return }, to ignore all low level error that is not important anymore, but the PHP manual do not tell me the detail about the error level, I even don't know the $errno bigger means it more serious or the opposite and which number of $errno, means can be safely ignored. I think a unique error code is needed here, but I know that may also cause some trouble on backwards compatibility. Oh, :-(
 [2010-05-14 19:29 UTC] dufuz (Helgi Þormar Þorbjörnsson)
You might want to read up on http://php.net/manual/en/function.error-reporting.php This would allow you to see all errors and notices but ignore the deprecated messages: error_reporting(E_ALL ^ E_DEPRECATED); You can also set this in you php.ini directly This way you do not have to do that if() in your error handler.
 [2010-05-15 06:21 UTC] walkinraven (Winfred Qin)
Thank you very much. You DO save me from the trouble!
 [2010-05-16 06:46 UTC] walkinraven (Winfred Qin)
New problem: I've found 'error_reporting' setting is ignored at all, anyone may refer to < http://www.php.net/manual/en/function.set-error-handler.php > where it says: 'error_reporting() settings will have no effect and your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately.' ----------------------------------- code: function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } ----------------------------------- I think the best way is to use a switch statement like 'PHP manual: set_error_handler, Example #1' And the error caused by 'PEAR::setErrorHandling(PEAR_ERROR_EXCEPTION);' is E_STRICT, not E_DEPRECATED.