Bug #62985 [Com]: set_exception_handler doesn't work from command line

From: Date: Fri, 31 Aug 2012 18:14:42 +0000
Subject: Bug #62985 [Com]: set_exception_handler doesn't work from command line
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-173069@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62985&edit=1

 ID:                 62985
 Comment by:         lgandras at gmail dot com
 Reported by:        lgandras at gmail dot com
 Summary:            set_exception_handler doesn't work from command line
 Status:             Open
 Type:               Bug
 Package:            *Configuration Issues
 Operating System:   CentoOS 6.2 x64
 PHP Version:        5.3.16
 Block user comment: N
 Private report:     N

 New Comment:

Temporary solution

echo '<?php set_exception_handler(function($e){echo "catched\n";});throw new
Exception;' | /usr/local/bin/php


Previous Comments:
------------------------------------------------------------------------
[2012-08-31 17:29:57] laruence@php.net

The following patch has been added/updated:

Patch Name: bug62985.patch
Revision:   1346434197
URL:        https://bugs.php.net/patch-display.php?bug=62985&patch=bug62985.patch&revision=1346434197

------------------------------------------------------------------------
[2012-08-31 17:28:35] laruence@php.net

a quick fix has been attached. but it is a change of zend API, so maybe someone 
else will have objections

------------------------------------------------------------------------
[2012-08-31 17:25:47] laruence@php.net

The following patch has been added/updated:

Patch Name: bug62985.patch
Revision:   1346433947
URL:        https://bugs.php.net/patch-display.php?bug=62985&patch=bug62985.patch&revision=1346433947

------------------------------------------------------------------------
[2012-08-31 16:40:05] lgandras at gmail dot com

Description:
------------
This is the output of my console:


# /usr/local/bin/php -v
PHP 5.3.16 (cli) (built: Aug 30 2012 18:38:54) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
# /usr/local/bin/php -r 'set_exception_handler(function(){echo "catched\n";});throw
new Exception;'

Fatal error: Uncaught exception 'Exception' in Command line code on line 1

Exception:  in Command line code on line 1

Call Stack:
    0.0002     632056   1. {main}() Command line code:0

root@vps:~#

Test script:
---------------
# /usr/local/bin/php -r 'set_exception_handler(function($e){echo
"catched!\n";});throw new Exception;'

Expected result:
----------------
catched!

Actual result:
--------------
Fatal error: Uncaught exception 'Exception' in Command line code on line 1

Exception:  in Command line code on line 1

Call Stack:
    0.0002     632056   1. {main}() Command line code:0


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62985&edit=1


Thread (10 messages)

« previous php.bugs (#173069) next »