Bug #65875 [NEW]: Stack trace and reflection failure on include/require.
| From: | RQuadling at GMail dot com | Date: | Thu, 10 Oct 2013 14:57:08 +0000 |
| Subject: | Bug #65875 [NEW]: Stack trace and reflection failure on include/require. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-182119@lists.php.net to get a copy of this message | ||
From: RQuadling at GMail dot com
Operating system: n/a
PHP version: Irrelevant
Package: Reflection related
Bug Type: Bug
Bug description:Stack trace and reflection failure on include/require.
Description:
------------
Hi.
debug_backtrace() contains 'function' or 'class' and 'function'
entries
to help you determine where the code came from.
No problem with that.
Except.
If the backtrace includes 'include' or 'require' (and their 'once'
variants'), these are reported as 'function' in the backtrace.
Again, no problem so far. Ish.
If you use ReflectionFunction or ReflectionMethod to gather and report
additional information about the trace, you get an error when dealing
with the include/require entries.
Uncaught exception 'ReflectionException' with message 'Function
require_once() does not exist'.
What is also interesting is that the output is slightly different for
include/require.
For a normal method/function, the order of the elements in the backtrace
are :
'file' => 'SomeClass.php',
'line' => 121,
'function' => 'SomeMethod',
'class' => 'SomeClass',
'type' => '->',
'args' =>
array (
),
But for include/require, ...
'file' => 'SomeFile.php',
'line' => 4,
'args' =>
array (
0 => '/incluldes/SomeClass.php',
),
'function' => 'require_once',
So, some specialisation already exists in the backtrace for these
non-functions.
This is confirmed at
https://github.com/php/php-src/blob/91a9569d8525d2893c83199ac83f973fb91e243b/Zend/zend_builtin_functions.c#L2345.
If the debug_backtrace could include a marker indicating that the
element in the trace is not reflected, OR, allow reflection of
include/require (and if there was a way for eval also), then this could
improve things a bit.
Though, I think, just a documentation upgrade in ReflectionXXX and
debug_xxx to indicate that code constructs are not reflected could cover
this.
--
Edit bug report at https://bugs.php.net/bug.php?id=65875&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65875&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=65875&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65875&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65875&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65875&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65875&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65875&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65875&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65875&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65875&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=65875&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=65875&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65875&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65875&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65875&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65875&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65875&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65875&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65875&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65875&r=mysqlcfg