From: jbq at caraldi dot com Operating system: GNU/Linux PHP version: 5.2.6 PHP Bug Type: Unknown/Other Function Bug description: Exception handler not invoked when using -r command line option
Description: ------------ When using the "-r" or "-run" command-line option to execute code, a custom exception handler is not invoked. Reproduce code: --------------- $ cat command_line_exception_handler.php <? function handler($e) { print "Caught exception " . $e->getMessage() . "\n"; } set_exception_handler("handler"); throw new Exception("Hello, World!"); Expected result: ---------------- $ php command_line_exception_handler.php Caught exception Hello, World! $ php -r "require 'command_line_exception_handler.php';" Caught exception Hello, World! Actual result: -------------- $ php command_line_exception_handler.php Caught exception Hello, World! $ php -r "require 'command_line_exception_handler.php';" Fatal error: Uncaught exception 'Exception' with message 'Hello, World!' in /home/jbq/command_line_exception_handler.php:6 Stack trace: #0 Command line code(1): require() #1 {main} thrown in /home/jbq/command_line_exception_handler.php on line 6 -- Edit bug report at http://bugs.php.net/?id=46305&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46305&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46305&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46305&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46305&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=46305&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46305&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46305&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46305&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46305&r=support Expected behavior: http://bugs.php.net/fix.php?id=46305&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46305&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46305&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46305&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46305&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46305&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46305&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46305&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46305&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46305&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46305&r=mysqlcfg