php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25038 call_user_func issues warning if function throws exception
Submitted: 2003-08-11 06:35 UTC Modified: 2003-12-27 16:06 UTC
Votes:5
Avg. Score:4.6 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: tater at potatoe dot com Assigned: helly (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.0b3 OS: *
Private report: No CVE-ID: None
 [2003-08-11 06:35 UTC] tater at potatoe dot com
Description:
------------
Throwing an exception from a function called by call_user_func() causes a warning to be issued,
saying it was unable to call the function.

An odd side note: if I set up my own error handler,
it does not receive this warning. Kind of an 
inadvertant workaround for now...

Reproduce code:
---------------
function bar($x='no argument')
{
    throw new Exception("This is an exception from bar({$x}).");
}
try { bar('first try'); }
catch (Exception $e) { print "{$e->message}\n"; }
try { call_user_func('bar','second try'); }
catch (Exception $e) { print "{$e->message}\n"; }

Expected result:
----------------
This is an exception from bar(first try).
This is an exception from bar(second try).


Actual result:
--------------
This is an exception from bar(first try).

Warning: call_user_func(bar): Unable to call bar(second try) in /my/pathname/test.php on line 8 
This is an exception from bar(second try).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-28 20:57 UTC] sniper@php.net
With latest CVS:

PHP Fatal error:  Cannot access protected property exception::$message in /home/jani/t.php on line 8

 [2003-11-29 00:06 UTC] tater at potatoe dot com
The Exception class seems to have changed since this bug was logged. So here is a new test case for you.

function bar($x='no argument')
{
        throw new Exception("This is an exception from bar({$x}).");
}
try { bar('first try'); }
catch (Exception $e) { print "{$e->getMessage()}\n"; }
try { call_user_func('bar','second try'); }
catch (Exception $e) { print "{$e->getMessage()}\n"; }

Same results.
 [2003-12-27 16:06 UTC] helly@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 [2004-08-23 01:48 UTC] technoweenie at gmail dot com
It says the bug is closed, but I'm having the same issue with the release versions of PHP 5/5.0.1 on Windows.  I also tried the latest snapshots for PHP 5.0.x and 5.1.x.  Did the fix not make it to the release version?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 02:01:28 2024 UTC