Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use WP_CLI\Utils\http_request() to fetch skip-content build #41

Merged
merged 2 commits into from
Oct 15, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions features/core-download.feature
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ Feature: Download WordPress
"""
Success: WordPress downloaded.
"""
And the wp-includes directory should exist
And the wp-content directory should not exist

Scenario: Core download without the wp-content dir should error for non US locale
Expand Down
2 changes: 1 addition & 1 deletion src/Core_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function download( $args, $assoc_args ) {

$no_content = '';
if ( true === \WP_CLI\Utils\get_flag_value( $assoc_args, 'skip-content' ) ) {
$response = Requests::get( 'https://api.wordpress.org/core/version-check/1.7/', null, array( 'timeout' => 30 ) );
$response = \WP_CLI\Utils\http_request( 'GET', 'https://api.wordpress.org/core/version-check/1.7/', null, array( 'timeout' => 30 ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty $headers args gotcha: $response = \WP_CLI\Utils\http_request( 'GET', 'https://api.wordpress.org/core/version-check/1.7/', null /*$data*/, array() /*$headers*/, array( 'timeout' => 30 ) );

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @gitlost. Removed entirely ea53ac6

if ( 200 === $response->status_code && ( $body = json_decode( $response->body ) ) && is_object( $body ) && isset( $body->offers[0]->packages->no_content ) && is_array( $body->offers ) ) {
$download_url = $body->offers[0]->packages->no_content;
$version = $body->offers[0]->version;
Expand Down