WordPress.org

Make WordPress Core

Changeset 39085


Ignore:
Timestamp:
11/02/16 03:44:00 (8 months ago)
Author:
rmccue
Message:

REST API: Remove the Location redirect for the /users/me endpoint.

This is a re-commit of [38980], which was reverted in [38990].

Props youknowriad, jnylen0, pento.
Fixes #38521.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    r39056 r39085  
    344344        $response = rest_ensure_response( $response ); 
    345345 
    346         $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $current_user_id ) ) ); 
    347         $response->set_status( 302 ); 
    348346 
    349347        return $response; 
  • trunk/tests/phpunit/tests/rest-api/rest-users-controller.php

    r39056 r39085  
    636636 
    637637        $response = $this->server->dispatch( $request ); 
    638         $this->assertEquals( 302, $response->get_status() ); 
     638        $this->assertEquals( 200, $response->get_status() ); 
    639639 
    640640        $headers = $response->get_headers(); 
    641         $this->assertArrayHasKey( 'Location', $headers ); 
    642         $this->assertEquals( rest_url( 'wp/v2/users/' . self::$user ), $headers['Location'] ); 
     641        $this->assertArrayNotHasKey( 'Location', $headers ); 
     642 
     643        $links = $response->get_links(); 
     644        $this->assertEquals( rest_url( 'wp/v2/users/' . self::$user ), $links['self'][0]['href'] ); 
    643645    } 
    644646 
Note: See TracChangeset for help on using the changeset viewer.