Make WordPress Core

Ticket #38521: 38521.diff

File 38521.diff, 1.6 KB (added by jnylen0, 9 years ago)
  • src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

     
    288288                $user = wp_get_current_user();
    289289                $response = $this->prepare_item_for_response( $user, $request );
    290290                $response = rest_ensure_response( $response );
    291                 $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $current_user_id ) ) );
    292                 $response->set_status( 302 );
    293291
    294292                return $response;
    295293        }
  • tests/phpunit/tests/rest-api/rest-users-controller.php

     
    627627                $request = new WP_REST_Request( 'GET', '/wp/v2/users/me' );
    628628
    629629                $response = $this->server->dispatch( $request );
    630                 $this->assertEquals( 302, $response->get_status() );
     630                $this->assertEquals( 200, $response->get_status() );
    631631
    632632                $headers = $response->get_headers();
    633                 $this->assertArrayHasKey( 'Location', $headers );
    634                 $this->assertEquals( rest_url( 'wp/v2/users/' . $this->user ), $headers['Location'] );
     633                $this->assertArrayNotHasKey( 'Location', $headers );
     634
     635                $links = $response->get_links();
     636                $this->assertEquals(
     637                        rest_url( 'wp/v2/users/' . $this->user ),
     638                        $links['self'][0]['href']
     639                );
    635640        }
    636641
    637642        public function test_get_current_user_without_permission() {