#31215 closed defect (bug) (fixed)
wp_debug_backtrace_summary fails if args index isn't set
Reported by: | paulschreiber | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | 3.4.1 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
In wp-includes/functions.php
, there's a function wp_debug_backtrace_summary()
.
If $call['args']
is undefined, it fails like so:
Notice: Undefined index: args in /srv/www/wp/wp-includes/functions.php on line 4493 Stack trace: 1. {main}() /srv/www/index.php:0 2. require() /srv/www/index.php:4 3. require_once() /srv/www/wp/wp-blog-header.php:16 4. include() /srv/www/wp/wp-includes/template-loader.php:74 5. Debug_Bar_PHP->error_handler() /srv/www/wp/wp-includes/template-loader.php:48 6. wp_debug_backtrace_summary() /srv/www/wp-content/plugins/debug-bar/panels/class-debug-bar-php.php:35
Here's line 4493:
$caller[] = $call['function'] . "('" . str_replace( array( WP_CONTENT_DIR, ABSPATH ) , '', $call['args'][0] ) . "')";
Change History (8)
#3
@
7 years ago
I don't recall what code I wrote in 2015 caused this problem. It could be avoided with isset()
checks.
#4
@
7 years ago
- Keywords reporter-feedback removed
- Milestone changed from Awaiting Review to 5.0
Reproduced when calling the function after including a non-existing file (in which case PHP also throws a warning).
#5
@
7 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 42824:
#6
follow-up:
↓ 7
@
7 years ago
Do you need to check isset( $call['args'], $call['args'][0] )
? Or will isset( $call['args'] )
work?
#7
in reply to:
↑ 6
@
7 years ago
Replying to paulschreiber:
Do you need to check
isset( $call['args'], $call['args'][0] )
? Or willisset( $call['args'] )
work?
Both would work, isset()
can check deeper array values without a notice. The commit actually checks for $call['args'][0]
.
Note: See
TracTickets for help on using
tickets.
Hi @paulschreiber, thanks for the report! Sorry it took so long for someone to get back to you.
I could not reproduce the issue neither in PHP 7.2.2 (the latest version at the moment) nor in PHP 5.2.4 (the earliest supported version).
Looking at the code,
$call
is the value ofdebug_backtrace()
. The affected line is only executed if$call['function']
is one ofinclude
,include_once
,require
, orrequire_once
, and in all of those cases$call['args']
is defined. It's even defined if I replacedebug_backtrace( false )
withdebug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS )
a few lines above.Could you clarify when
$call['args']
would be undefined? Looks like there are no other reports of this issue.