php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65875 Stack trace and reflection failure on include/require.
Submitted: 2013-10-10 14:57 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: RQuadling at GMail dot com Assigned:
Status: Open Package: Reflection related
PHP Version: Irrelevant OS: n/a
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-10-10 14:57 UTC] RQuadling at GMail dot com
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.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-10 23:33 UTC] kenorb at gmail dot com
Still happening in PHP 5.4.19
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 21:01:30 2024 UTC