Skip to content

Commit 8699e49

Browse files
Merge branch 'master' into issue/doc-verbs
2 parents 8583147 + 0821866 commit 8699e49

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

src/Plugin_Command.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,14 @@ protected function install_from_repo( $slug, $assoc_args ) {
501501
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'version' ) != 'dev' ) {
502502
WP_CLI::get_http_cache_manager()->whitelist_package( $api->download_link, $this->item_type, $api->slug, $api->version );
503503
}
504+
505+
// Ignore failures on accessing SSL "https://api.wordpress.org/plugins/update-check/1.1/" in `wp_update_plugins()` which seem to occur intermittently.
506+
set_error_handler( array( __CLASS__, 'error_handler' ), E_USER_WARNING | E_USER_NOTICE );
507+
504508
$result = $this->get_upgrader( $assoc_args )->install( $api->download_link );
505509

510+
restore_error_handler();
511+
506512
return $result;
507513
}
508514

@@ -622,7 +628,7 @@ protected function get_item_list() {
622628
'version' => $details['Version'],
623629
'update_id' => $file,
624630
'title' => $details['Name'],
625-
'description' => $details['Description'],
631+
'description' => wordwrap( $details['Description'] ),
626632
);
627633
}
628634

src/Theme_Command.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,14 @@ protected function install_from_repo( $slug, $assoc_args ) {
411411
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'version' ) != 'dev' ) {
412412
WP_CLI::get_http_cache_manager()->whitelist_package( $api->download_link, $this->item_type, $api->slug, $api->version );
413413
}
414+
415+
// Ignore failures on accessing SSL "https://api.wordpress.org/themes/update-check/1.1/" in `wp_update_themes()` which seem to occur intermittently.
416+
set_error_handler( array( __CLASS__, 'error_handler' ), E_USER_WARNING | E_USER_NOTICE );
417+
414418
$result = $this->get_upgrader( $assoc_args )->install( $api->download_link );
415419

420+
restore_error_handler();
421+
416422
return $result;
417423
}
418424

@@ -442,7 +448,7 @@ protected function get_item_list() {
442448
'version' => $theme->get('Version'),
443449
'update_id' => $theme->get_stylesheet(),
444450
'title' => $theme->get('Name'),
445-
'description' => $theme->get('Description'),
451+
'description' => wordwrap( $theme->get('Description') ),
446452
'author' => $theme->get('Author'),
447453
);
448454

src/WP_CLI/CommandWithUpgrade.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,5 +626,23 @@ protected function get_formatter( &$assoc_args ) {
626626
return new \WP_CLI\Formatter( $assoc_args, $this->obj_fields, $this->item_type );
627627
}
628628

629+
/**
630+
* Error handler to ignore failures on accessing SSL "https://api.wordpress.org/themes/update-check/1.1/" in `wp_update_themes()`
631+
* and "https://api.wordpress.org/plugins/update-check/1.1/" in `wp_update_plugins()` which seem to occur intermittently.
632+
*/
633+
public static function error_handler( $errno, $errstr, $errfile, $errline, $errcontext = null ) {
634+
// If ignoring E_USER_WARNING | E_USER_NOTICE, default.
635+
if ( ! ( error_reporting() & $errno ) ) {
636+
return false;
637+
}
638+
// If not in "wp-includes/update.php", default.
639+
$update_php = 'wp-includes/update.php';
640+
if ( 0 !== substr_compare( $errfile, $update_php, -strlen( $update_php ) ) ) {
641+
return false;
642+
}
643+
// Else assume it's in `wp_update_themes()` or `wp_update_plugins()` and just ignore it.
644+
return true;
645+
}
646+
629647
}
630648

0 commit comments

Comments
 (0)