mirror of
https://hk.gh-proxy.com/https://github.com/wp-cli/profile-command.git
synced 2025-08-21 06:38:51 +08:00
Merge pull request #70 from runcommand/catch-exceptions
Catch hook Exceptions incrementally
This commit is contained in:
commit
e0af87e156
2 changed files with 28 additions and 8 deletions
|
@ -8,3 +8,14 @@ Feature: Profile a specific hook
|
|||
| callback |
|
||||
| total |
|
||||
And STDERR should be empty
|
||||
|
||||
Scenario: Profile a hook that has actions with output
|
||||
Given a WP install
|
||||
|
||||
When I run `wp profile --hook=wp_head --fields=callback`
|
||||
Then STDOUT should be a table containing rows:
|
||||
| callback |
|
||||
And STDOUT should not contain:
|
||||
"""
|
||||
<meta name="generator"
|
||||
"""
|
||||
|
|
|
@ -72,11 +72,7 @@ class Command {
|
|||
WP_CLI::add_wp_hook( 'all', array( $this, 'wp_hook_begin' ) );
|
||||
WP_CLI::add_wp_hook( 'pre_http_request', array( $this, 'wp_request_begin' ) );
|
||||
WP_CLI::add_wp_hook( 'http_api_debug', array( $this, 'wp_request_end' ) );
|
||||
try {
|
||||
$this->load_wordpress_with_template();
|
||||
} catch( \Exception $e ) {
|
||||
// pass through
|
||||
}
|
||||
$this->load_wordpress_with_template();
|
||||
|
||||
if ( $this->focus_stage ) {
|
||||
$fields = array(
|
||||
|
@ -266,7 +262,11 @@ class Command {
|
|||
$logger = new Logger( 'stage', 'bootstrap' );
|
||||
$logger->start();
|
||||
}
|
||||
WP_CLI::get_runner()->load_wordpress();
|
||||
try {
|
||||
WP_CLI::get_runner()->load_wordpress();
|
||||
} catch( \Exception $e ) {
|
||||
// pass through
|
||||
}
|
||||
if ( ! $this->focus_stage && ! $this->focus_hook ) {
|
||||
$logger->stop();
|
||||
$this->loggers[] = $logger;
|
||||
|
@ -285,7 +285,11 @@ class Command {
|
|||
$logger = new Logger( 'stage', 'main_query' );
|
||||
$logger->start();
|
||||
}
|
||||
wp();
|
||||
try {
|
||||
wp();
|
||||
} catch( \Exception $e ) {
|
||||
// pass through
|
||||
}
|
||||
if ( ! $this->focus_stage && ! $this->focus_hook ) {
|
||||
$logger->stop();
|
||||
$this->loggers[] = $logger;
|
||||
|
@ -313,12 +317,17 @@ class Command {
|
|||
$logger->start();
|
||||
}
|
||||
ob_start();
|
||||
require_once( ABSPATH . WPINC . '/template-loader.php' );
|
||||
try {
|
||||
require_once( ABSPATH . WPINC . '/template-loader.php' );
|
||||
} catch( \Exception $e ) {
|
||||
// pass through
|
||||
}
|
||||
ob_get_clean();
|
||||
if ( ! $this->focus_stage && ! $this->focus_hook ) {
|
||||
$logger->stop();
|
||||
$this->loggers[] = $logger;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue