WordPress.org

Make WordPress Core

Changeset 25956


Ignore:
Timestamp:
10/27/2013 09:08:25 PM (7 years ago)
Author:
nacin
Message:

When an HTTPS request to api.wordpress.org fails, try an insecure HTTP request and issue a warning.

Certain versions of cURL appear to claim OpenSSL support but fail to work. We need to not trap users on older versions while we work this out, and instead fall back to an insecure request.

see #25716 for trunk.

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/about.php

    r25883 r25956  
    6262            require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    6363            $updater = new WP_Automatic_Updater;
    64             $can_auto_update = wp_http_supports( 'ssl' ) && $updater->should_update( 'core', $future_minor_update, ABSPATH );
     64            $can_auto_update = wp_http_supports( array( 'ssl' ) ) && $updater->should_update( 'core', $future_minor_update, ABSPATH );
    6565
    6666            if ( $can_auto_update ) {
  • trunk/src/wp-admin/includes/plugin-install.php

    r25691 r25956  
    6161
    6262    if ( false === $res ) {
    63         $url = 'http://api.wordpress.org/plugins/info/1.0/';
    64         if ( wp_http_supports( array( 'ssl' ) ) )
     63        $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
     64        if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
    6565            $url = set_url_scheme( $url, 'https' );
    6666
    67         $request = wp_remote_post( $url, array(
     67        $args = array(
    6868            'timeout' => 15,
    6969            'body' => array(
     
    7171                'request' => serialize( $args )
    7272            )
    73         ) );
     73        );
     74        $request = wp_remote_post( $url, $args );
     75
     76        if ( $ssl && is_wp_error( $request ) ) {
     77            trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.' ) . ' ' . '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)', headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
     78            $request = wp_remote_post( $http_url, $args );
     79        }
    7480
    7581        if ( is_wp_error($request) ) {
  • trunk/src/wp-admin/includes/theme.php

    r25308 r25956  
    283283
    284284    if ( ! $res ) {
    285         $url = 'http://api.wordpress.org/themes/info/1.0/';
    286         if ( wp_http_supports( array( 'ssl' ) ) )
     285        $url = $http_url = 'http://api.wordpress.org/themes/info/1.0/';
     286        if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
    287287            $url = set_url_scheme( $url, 'https' );
    288288
    289         $request = wp_remote_post( $url, array(
     289        $args = array(
    290290            'body' => array(
    291291                'action' => $action,
    292292                'request' => serialize( $args )
    293293            )
    294         ) );
     294        );
     295        $request = wp_remote_post( $url, $args );
     296
     297        if ( $ssl && is_wp_error( $request ) ) {
     298            trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.' ) . ' ' . '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)', headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
     299            $request = wp_remote_post( $http_url, $args );
     300        }
    295301
    296302        if ( is_wp_error($request) ) {
  • trunk/src/wp-admin/includes/update.php

    r25872 r25956  
    104104    $return = array();
    105105
    106     $url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' );
    107 
    108     if ( wp_http_supports( array( 'ssl' ) ) )
     106    $url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' );
     107
     108    if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
    109109        $url = set_url_scheme( $url, 'https' );
    110110
     
    114114
    115115    $response = wp_remote_get( $url, $options );
     116    if ( $ssl && is_wp_error( $response ) ) {
     117        trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.' ) . ' ' . '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)', headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
     118        $response = wp_remote_get( $http_url, $options );
     119    }
    116120
    117121    if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
  • trunk/src/wp-admin/update-core.php

    r25880 r25956  
    147147        _e('You have the latest version of WordPress.');
    148148
    149         if ( wp_http_supports( 'ssl' ) ) {
     149        if ( wp_http_supports( array( 'ssl' ) ) ) {
    150150            require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    151151            $upgrader = new WP_Automatic_Updater;
  • trunk/src/wp-includes/update.php

    r25880 r25956  
    9494        $post_body = array_merge( $post_body, $extra_stats );
    9595
    96     $url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' );
    97     if ( wp_http_supports( array( 'ssl' ) ) )
     96    $url = $http_url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' );
     97    if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
    9898        $url = set_url_scheme( $url, 'https' );
    9999
     
    109109
    110110    $response = wp_remote_post( $url, $options );
     111    if ( $ssl && is_wp_error( $response ) ) {
     112        trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.' ) . ' ' . '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)', headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
     113        $response = wp_remote_post( $http_url, $options );
     114    }
    111115
    112116    if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
     
    247251    );
    248252
    249     $url = 'http://api.wordpress.org/plugins/update-check/1.1/';
    250     if ( wp_http_supports( array( 'ssl' ) ) )
     253    $url = $http_url = 'http://api.wordpress.org/plugins/update-check/1.1/';
     254    if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
    251255        $url = set_url_scheme( $url, 'https' );
    252256
    253257    $raw_response = wp_remote_post( $url, $options );
     258    if ( $ssl && is_wp_error( $raw_response ) ) {
     259        trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.' ) . ' ' . '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)', headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
     260        $raw_response = wp_remote_post( $http_url, $options );
     261    }
    254262
    255263    if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) )
     
    383391    );
    384392
    385     $url = 'http://api.wordpress.org/themes/update-check/1.1/';
    386     if ( wp_http_supports( array( 'ssl' ) ) )
     393    $url = $http_url = 'http://api.wordpress.org/themes/update-check/1.1/';
     394    if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
    387395        $url = set_url_scheme( $url, 'https' );
    388396
    389397    $raw_response = wp_remote_post( $url, $options );
     398    if ( $ssl && is_wp_error( $raw_response ) ) {
     399        trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.' ) . ' ' . '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)', headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
     400        $raw_response = wp_remote_post( $http_url, $options );
     401    }
    390402
    391403    if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) )
Note: See TracChangeset for help on using the changeset viewer.