From 6a2052244a76ee2fa8d2351eb85a17ca9d65ffab Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 19 Oct 2016 04:56:53 -0700 Subject: [PATCH] Start profiling right away when profiling `muplugins_loaded:before` --- inc/class-profiler.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/inc/class-profiler.php b/inc/class-profiler.php index 0fd11b7..20812b7 100644 --- a/inc/class-profiler.php +++ b/inc/class-profiler.php @@ -98,8 +98,12 @@ class Profiler { } $end_hook = substr( $this->focus, 0, -7 ); $key = array_search( $end_hook, $stage_hooks ); - $start_hook = $stage_hooks[ $key - 1 ]; - WP_CLI::add_wp_hook( $start_hook, array( $this, 'wp_tick_profile_begin' ), 9999 ); + if ( isset( $stage_hooks[ $key - 1 ] ) ) { + $start_hook = $stage_hooks[ $key - 1 ]; + WP_CLI::add_wp_hook( $start_hook, array( $this, 'wp_tick_profile_begin' ), 9999 ); + } else { + WP_CLI::add_hook( 'after_wp_config_load', array( $this, 'wp_tick_profile_begin' ) ); + } WP_CLI::add_wp_hook( $end_hook, array( $this, 'wp_tick_profile_end' ), -9999 ); } else { WP_CLI::add_wp_hook( 'all', array( $this, 'wp_hook_begin' ) );