Skip to content

Commit f2ae20b

Browse files
Merge pull request #182 from wp-cli/181-circumvent-travis-ssl-issue
Work around Travis CI issue with _s download certificate
2 parents 7529677 + dd33fc7 commit f2ae20b

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

features/scaffold.feature

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ Feature: WordPress code scaffolding
338338
Given I run `wp theme path`
339339
And save STDOUT as {THEME_DIR}
340340
341-
When I run `wp scaffold _s starter-theme`
341+
# Allow for warnings to be generated due to https://github.com/wp-cli/scaffold-command/issues/181
342+
When I try `wp scaffold _s starter-theme`
342343
Then STDOUT should contain:
343344
"""
344345
Success: Created theme 'Starter-theme'.
@@ -351,7 +352,8 @@ Feature: WordPress code scaffolding
351352
Given I run `wp theme path`
352353
And save STDOUT as {THEME_DIR}
353354
354-
When I run `wp scaffold _s starter-theme --sassify`
355+
# Allow for warnings to be generated due to https://github.com/wp-cli/scaffold-command/issues/181
356+
When I try `wp scaffold _s starter-theme --sassify`
355357
Then STDOUT should contain:
356358
"""
357359
Success: Created theme 'Starter-theme'.
@@ -363,7 +365,8 @@ Feature: WordPress code scaffolding
363365
Given I run `wp theme path`
364366
And save STDOUT as {THEME_DIR}
365367
366-
When I run `wp scaffold _s starter-theme --woocommerce`
368+
# Allow for warnings to be generated due to https://github.com/wp-cli/scaffold-command/issues/181
369+
When I try `wp scaffold _s starter-theme --woocommerce`
367370
Then STDOUT should contain:
368371
"""
369372
Success: Created theme 'Starter-theme'.
@@ -373,7 +376,8 @@ Feature: WordPress code scaffolding
373376
374377
Scenario: Scaffold starter code for a theme and activate it
375378
Given a WP install
376-
When I run `wp scaffold _s starter-theme --activate`
379+
# Allow for warnings to be generated due to https://github.com/wp-cli/scaffold-command/issues/181
380+
When I try `wp scaffold _s starter-theme --activate`
377381
Then STDOUT should contain:
378382
"""
379383
Success: Switched to 'Starter-theme' theme.
@@ -488,7 +492,8 @@ Feature: WordPress code scaffolding
488492
489493
Scenario: Scaffold starter code for a theme and network enable it
490494
Given a WP multisite install
491-
When I run `wp scaffold _s starter-theme --enable-network`
495+
# Allow for warnings to be generated due to https://github.com/wp-cli/scaffold-command/issues/181
496+
When I try `wp scaffold _s starter-theme --enable-network`
492497
Then STDOUT should contain:
493498
"""
494499
Success: Network enabled the 'Starter-theme' theme.

src/Scaffold_Command.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,13 +400,25 @@ public function _s( $args, $assoc_args ) {
400400
$body['underscoresme_woocommerce'] = 1;
401401
}
402402

403-
$tmpfname = wp_tempnam( $url );
404-
$response = wp_remote_post( $url, array(
403+
$tmpfname = wp_tempnam( $url );
404+
$post_args = array(
405405
'timeout' => $timeout,
406406
'body' => $body,
407407
'stream' => true,
408408
'filename' => $tmpfname,
409-
) );
409+
);
410+
411+
$response = wp_remote_post( $url, $post_args );
412+
413+
// Workaround to get scaffolding to work within Travis CI.
414+
// See https://github.com/wp-cli/scaffold-command/issues/181
415+
if ( is_wp_error( $response )
416+
&& false !== strpos( $response->get_error_message(), 'gnutls_handshake() failed' ) ) {
417+
// Certificate problem, falling back to unsecured request instead.
418+
$alt_url = str_replace( 'https://', 'http://', $url );
419+
WP_CLI::warning( "Secured request to {$url} failed, using {$alt_url} as a fallback." );
420+
$response = wp_remote_post( $alt_url, $post_args );
421+
}
410422

411423
if ( is_wp_error( $response ) ) {
412424
WP_CLI::error( $response );

0 commit comments

Comments
 (0)