From: colin at mms3 dot com
Operating system: Linux (2.4)
PHP version: 4.3.8
PHP Bug Type: Output Control
Bug description: error handler not used by create_function parser
Description:
------------
I am writing an application which allows the 'user' to specify some PHP
code. This is then invoked at run-time by the create_function() function.
I want to provide a facility for pre-checking this code by using a custom
error-handler, however the errors seem to be getting handled by the
built-in error handler.
Reproduce code:
---------------
function lister_check_errors($errno, $errstr, $errfile, $errline)
{
global $lister_embed_errors;
$lister_embed_errors.="$errno: $errstr<br />\n in line
$errline";
}
function lister_check_syntax($code,$params)
{
global $lister_embed_errors;
$lister_embed_errors='';
$errhandler=set_error_handler('lister_check_errors');
$fn=create_function($params,$code);
restore_error_handler();
return($lister_embed_errors);
}
$stored=lister_check_syntax("{{{{ bad stuff", '$something');
print strlen($stored);
Expected result:
----------------
I expected to just get an integer back, but it behaves as if I hadn't
called set_error_handler()
Actual result:
--------------
The following was output to the browser:
Parse error: parse error, unexpected T_STRING in
/home/colin/public_html/form/check_err.php(15) : runtime-created function
on line 1
--
Edit bug report at http://bugs.php.net/?id=29550&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29550&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29550&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29550&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29550&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29550&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29550&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29550&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29550&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29550&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29550&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29550&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29550&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29550&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29550&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29550&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29550&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29550&r=float