diff --git a/includes/class-wc-background-updater.php b/includes/class-wc-background-updater.php index 3864f9bf65c..d50fea96c14 100644 --- a/includes/class-wc-background-updater.php +++ b/includes/class-wc-background-updater.php @@ -29,11 +29,31 @@ class WC_Background_Updater extends WP_Background_Process { protected $action = 'wc_updater'; /** - * Dispatch + * @var string + */ + protected $error = ''; + + /** + * Dispatch updater. + * + * Updater will still run via cron job if this fails for any reason. */ public function dispatch() { WC_Admin_Notices::add_notice( 'updating' ); - parent::dispatch(); + + $dispatched = parent::dispatch(); + + if ( is_wp_error( $dispatched ) ) { + $this->error = $dispatched->get_error_message(); + add_action( 'admin_notices', array( $this, 'dispatch_error' ) ); + } + } + + /** + * Error shown when the updater cannot dispatch. + */ + public function dispatch_error() { + echo '

' . __( 'Unable to dispatch WooCommerce updater:', 'woocommerce' ) . ' ' . esc_html( $this->error ) . '

'; } /** diff --git a/includes/libraries/wp-background-process.php b/includes/libraries/wp-background-process.php index 852e3419d83..fa57161902f 100755 --- a/includes/libraries/wp-background-process.php +++ b/includes/libraries/wp-background-process.php @@ -48,7 +48,7 @@ if ( ! class_exists( 'WP_Background_Process' ) ) { $this->schedule_event(); // Perform remote post - parent::dispatch(); + return parent::dispatch(); } /**