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

Fix bugs for a multisite environment. #15

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion wp-includes/rest-api/auth/class-wp-rest-key-pair.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static function get_rest_uri() {
$prefix = rest_get_url_prefix();
}

return sprintf( '/%s/%s/%s', $prefix, self::_NAMESPACE_, self::_REST_BASE_ );
return sprintf( '%s/%s/%s/%s', get_home_url(), $prefix, self::_NAMESPACE_, self::_REST_BASE_ );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why add the home url here? This will break the tests and would require some additional modifications.

}

/**
Expand Down
8 changes: 8 additions & 0 deletions wp-includes/rest-api/auth/class-wp-rest-token.php
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,14 @@ public function get_auth_header() {
$header = sanitize_text_field( $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] );
}

//Maybe apache?
Copy link
Collaborator

@valendesigns valendesigns Jul 5, 2019

Choose a reason for hiding this comment

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

This whole block of code does not adhere to coding standards and is causing phpcs to fail the build. Please update it when you have a chance.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps it would make more sense to check for the missing header at the same time as the check for the function.

// Fallback for Apache request headers.
if ( ! $header && function_exists( 'apache_request_headers' ) ) {
    $headers = apache_request_headers();
    if ( is_array( $headers ) && ! empty( $headers[ 'Authorization' ] ) ) {
        $header = sanitize_text_field( $headers[ 'Authorization' ] );
    }
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't have anything to do with Multisite though. Can you describe the problem you're having with Multisite so I can understand why you are changing the rest endpoint?

if( function_exists('apache_request_headers') ) {
$headers = apache_request_headers();
if (! $header && is_array($headers) && isset($headers['Authorization'])) {
$header = sanitize_text_field( $headers['Authorization'] );
}
}

// The HTTP Authorization Header is missing, return an error.
if ( ! $header ) {
return new WP_Error(
Expand Down