Skip to content

Commit

Permalink
Must load Bitbucket auth headers earlier
Browse files Browse the repository at this point in the history
Should fix #482
  • Loading branch information
afragen committed Oct 28, 2016
1 parent a225b70 commit 5893f11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
8 changes: 8 additions & 0 deletions src/GitHub_Updater/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ public function load_hooks() {
add_action( 'wp_ajax_github-updater-update', array( &$this, 'ajax_update' ) );
add_action( 'wp_ajax_nopriv_github-updater-update', array( &$this, 'ajax_update' ) );

/*
* Load hooks for Bitbucket authentication headers.
*/
$bitbucket = new Bitbucket_API( new \stdClass() );
add_filter( 'http_request_args', array( &$bitbucket, 'maybe_authenticate_http' ), 10, 2 );
add_filter( 'http_request_args', array( &$bitbucket, 'http_release_asset_auth' ), 15, 2 );
add_filter( 'http_request_args', array( &$bitbucket, 'ajax_maybe_authenticate_http' ), 15, 2 );

add_filter( 'extra_theme_headers', array( &$this, 'add_headers' ) );
add_filter( 'extra_plugin_headers', array( &$this, 'add_headers' ) );
add_filter( 'upgrader_source_selection', array( &$this, 'upgrader_source_selection' ), 10, 4 );
Expand Down
11 changes: 0 additions & 11 deletions src/GitHub_Updater/Bitbucket_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public function __construct( $type ) {
parent::$hours = 12;
$this->response = $this->get_transient();

$this->load_hooks();

if ( ! isset( self::$options['bitbucket_username'] ) ) {
self::$options['bitbucket_username'] = null;
}
Expand All @@ -48,15 +46,6 @@ public function __construct( $type ) {
add_site_option( 'github_updater', self::$options );
}

/**
* Load hooks for Bitbucket authentication headers.
*/
public function load_hooks() {
add_filter( 'http_request_args', array( &$this, 'maybe_authenticate_http' ), 10, 2 );
add_filter( 'http_request_args', array( &$this, 'http_release_asset_auth' ), 15, 2 );
add_filter( 'http_request_args', array( &$this, 'ajax_maybe_authenticate_http' ), 15, 2 );
}

/**
* Remove hooks for Bitbucket authentication headers.
*/
Expand Down

0 comments on commit 5893f11

Please sign in to comment.