deliciousbrains / wp-migrate-db

WordPress plugin that exports your database, does a find and replace on URLs and file paths, then allows you to save it to your computer.
https://wordpress.org/plugins/wp-migrate-db/
342 stars 515 forks source link

When using https and response is 401, Connection Info should be not rewritten to http #60

Closed adagio closed 6 years ago

adagio commented 8 years ago

class/wpmdb-base.php

this case should match the elseif('401' .... but matches the if( 0 === strpos ...

} elseif ( 200 > (int) $response['response']['code'] || 399 < (int) $response['response']['code'] ) { if ( 0 === strpos( $url, 'https://' ) && 'ajax_verify_connection_to_remote_site' == $scope ) { return $this->retry_remote_post( $url, $data, $scope, $args, $expecting_serial ); } elseif ( '401' == $response['response']['code'] ) {

mattgrshaw commented 8 years ago

@adagio Thanks for the heads up on this, we'll look into getting this fixed for the next release. It looks like switching the order of the statements is enough to fix the issue:

        if ( 401 === (int) $response['response']['code'] ) {
            $this->error = __( 'The remote site is protected with Basic Authentication. Please enter the username and password above to continue. (401 Unauthorized)', 'wp-migrate-db' );
            $this->log_error( $this->error, $response );

            return false;
        } elseif ( 0 === strpos( $url, 'https://' ) && 'ajax_verify_connection_to_remote_site' == $scope ) {
            return $this->retry_remote_post( $url, $data, $scope, $args, $expecting_serial );
        } ...