WordPress.org

WordPress build repository browser

Changeset 41078


Ignore:
Timestamp:
08/10/17 01:38:43 (12 days ago)
Author:
jnylen0
Message:

REST API: Always call rest_get_server() instead of accessing the $wp_rest_server global.

This is a consistency improvement and also a bug fix for fairly obscure cases involving modified WP load order.

Fixes #41555.

Built from https://develop.svn.wordpress.org/trunk@41238

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/rest-api.php

    r40979 r41078  
    1919 * 
    2020 * @since 4.4.0 
    21  * 
    22  * @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server). 
    2321 * 
    2422 * @param string $namespace The first URL segment after core prefix. Should be unique to your package/plugin. 
     
    3129 */ 
    3230function register_rest_route( $namespace, $route, $args = array(), $override = false ) { 
    33     /** @var WP_REST_Server $wp_rest_server */ 
    34     global $wp_rest_server; 
    35  
    3631    if ( empty( $namespace ) ) { 
    3732        /* 
     
    7570 
    7671    $full_route = '/' . trim( $namespace, '/' ) . '/' . trim( $route, '/' ); 
    77     $wp_rest_server->register_route( $namespace, $full_route, $args, $override ); 
     72    rest_get_server()->register_route( $namespace, $full_route, $args, $override ); 
    7873    return true; 
    7974} 
     
    246241 * 
    247242 * @global WP             $wp             Current WordPress environment instance. 
    248  * @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server). 
    249243 */ 
    250244function rest_api_loaded() { 
     
    388382 * @since 4.4.0 
    389383 * 
    390  * @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server). 
    391  * 
    392384 * @param WP_REST_Request|string $request Request. 
    393385 * @return WP_REST_Response REST response. 
     
    705697 * 
    706698 * @global mixed          $wp_rest_auth_cookie 
    707  * @global WP_REST_Server $wp_rest_server      REST server instance. 
    708699 * 
    709700 * @param WP_Error|mixed $result Error from another authentication handler, 
     
    717708    } 
    718709 
    719     global $wp_rest_auth_cookie, $wp_rest_server; 
     710    global $wp_rest_auth_cookie; 
    720711 
    721712    /* 
     
    751742 
    752743    // Send a refreshed nonce in header. 
    753     $wp_rest_server->send_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) ); 
     744    rest_get_server()->send_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) ); 
    754745 
    755746    return true; 
  • trunk/wp-includes/version.php

    r41077 r41078  
    55 * @global string $wp_version 
    66 */ 
    7 $wp_version = '4.9-alpha-41237'; 
     7$wp_version = '4.9-alpha-41238'; 
    88 
    99/** 
Note: See TracChangeset for help on using the changeset viewer.