From:
Operating system: All
PHP version: 5.3.8
Package: *General Issues
Bug Type: Feature/Change Request
Bug description:Implement ability to recover from fatal errors in eval()'d code
Description:
------------
Sometimes eval() is used as a way to execute PHP code within a shell (legal
remote access for debugging purposes) or to execute code compiled to PHP
from higher-level scripting language or the code stored in the database
etc.
The common problem is that a call of non-existing function (or object
instantiation) results in termination of the whole script, not just eval'd
code.
I think that it's not correct in such cases.
The obvious way to implement it would be adding flags to eval() function
(as a second argument) one of which could indicate that eval() should not
terminate the script but just return an error or raise an exception.
Such flags could be:
EVAL_FATAL_DIE // current behavior
EVAL_FATAL_ERROR // return FALSE
EVAL_FATAL_EXCEPTION // raise an exception of a predefined class (e.g.
EvalException)
Test script:
---------------
try {
eval('non_existing_function()', EVAL_FATAL_EXCEPTION);
}
catch (EvalException $e) {
Logger::log('Error in eval\'d code', $e);
}
Expected result:
----------------
Exception being logged and script continued its execution.
Actual result:
--------------
Fatal error: Call to undefined function non_existing_function() in ... :
eval()'d code(1) on line 1
--
Edit bug report at https://bugs.php.net/bug.php?id=60364&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=60364&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=60364&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=60364&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=60364&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=60364&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=60364&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=60364&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=60364&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=60364&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=60364&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=60364&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=60364&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=60364&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=60364&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=60364&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60364&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=60364&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=60364&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=60364&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=60364&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=60364&r=mysqlcfg