From 7d43c0eb658b2070b10989b977459cd7287d3922 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Thu, 25 Oct 2018 11:22:14 +0200 Subject: [PATCH] Work around Travis CI issue with _s download certificate When the request fails on HTTPS, we switch to HTTP instead, which should work within Travis. Fixes #181 --- src/Scaffold_Command.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Scaffold_Command.php b/src/Scaffold_Command.php index 057575696..d71316267 100644 --- a/src/Scaffold_Command.php +++ b/src/Scaffold_Command.php @@ -408,6 +408,21 @@ public function _s( $args, $assoc_args ) { 'filename' => $tmpfname, ) ); + // Workaround to get scaffolding to work within Travis CI. + // See https://github.com/wp-cli/scaffold-command/issues/181 + if ( is_wp_error( $response ) + && false !== strpos( $response->get_error_message(), 'gnutls_handshake() failed' ) ) { + // Try again with HTTP instead of HTTPS. + $url = str_replace( 'https://', 'http://', $url ); + + $response = wp_remote_post( $url, array( + 'timeout' => $timeout, + 'body' => $body, + 'stream' => true, + 'filename' => $tmpfname, + ) ); + } + if ( is_wp_error( $response ) ) { WP_CLI::error( $response ); }