From 8e936d5861dbe63ae82211cfc8fdab7b28428810 Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Mon, 11 Sep 2017 15:02:33 -0700 Subject: [PATCH] Better use of `use`, and shorter comments to allow for more of the message --- includes/run.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/run.php b/includes/run.php index a5a5ac0..39421ed 100644 --- a/includes/run.php +++ b/includes/run.php @@ -6,6 +6,7 @@ */ namespace Automattic\WP\WP_CLI_Cron_Control_Offload; +use WP_CLI; /** * Intended for non-interactive use, so all output ends up in the error log @@ -23,13 +24,13 @@ function run_event( $command ) { if ( ! validate_command( $command ) ) { /* translators: 1: Plugin's prefix for log messages, 2. WP-CLI command that would have run */ - trigger_error( sprintf( __( '%1$s: Attempted to run blocked WP-CLI command. (%2$s)', 'wp-cli-cron-control-offload' ), MESSAGE_PREFIX, var_export( $command, true ) ), E_USER_WARNING ); + trigger_error( sprintf( __( '%1$s: Attempted to run blocked command. (%2$s)', 'wp-cli-cron-control-offload' ), MESSAGE_PREFIX, var_export( $command, true ) ), E_USER_WARNING ); return; } $start = microtime( true ); - $output = \WP_CLI::runcommand( $command, array( + $output = WP_CLI::runcommand( $command, array( 'exit_error' => false, // Don't kill the cron process if the WP-CLI command fails, otherwise we can't capture the error. 'launch' => true, // Don't reuse as we're in cron context. 'return' => 'all', // We want STDERR and the exit code, in addition to STDOUT. @@ -40,7 +41,7 @@ function run_event( $command ) { // Command failed. if ( ! is_object( $output ) || is_wp_error( $output ) ) { /* translators: 1: Plugin's prefix for log messages, 2. Command error that caused failure */ - trigger_error( sprintf( __( '%1$s: WP-CLI command failed. (%2$s)', 'wp-cli-cron-control-offload' ), MESSAGE_PREFIX, var_export( $command, true ) ), E_USER_WARNING ); + trigger_error( sprintf( __( '%1$s: Command failed. (%2$s)', 'wp-cli-cron-control-offload' ), MESSAGE_PREFIX, var_export( $command, true ) ), E_USER_WARNING ); $message = is_wp_error( $output ) ? $output->get_error_message() : var_export( $output, true ); trigger_error( $message, E_USER_WARNING ); -- GitLab