WordPress.org

Make WordPress Core

Changeset 44173 for trunk


Ignore:
Timestamp:
12/14/2018 06:03:35 AM (2 years ago)
Author:
pento
Message:

REST API: Improve performance by avoiding call_user_func().

The get_compact_response_links() method was introduced in WP 4.5, and this conditional is no longer necessary.

Merges [43834] from the 5.0 branch to trunk.

Props schlessera, timothyblynjacobs.
Fixes #45189.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/rest-api.php

    r44172 r44173  
    13681368        $server = rest_get_server();
    13691369        $data   = (array) $response->get_data();
    1370         if ( method_exists( $server, 'get_compact_response_links' ) ) {
    1371             $links = call_user_func( array( $server, 'get_compact_response_links' ), $response );
    1372         } else {
    1373             $links = call_user_func( array( $server, 'get_response_links' ), $response );
    1374         }
     1370        $links  = $server->get_compact_response_links( $response );
    13751371        if ( ! empty( $links ) ) {
    13761372            $data['_links'] = $links;
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php

    r43986 r44173  
    213213        $data   = (array) $response->get_data();
    214214        $server = rest_get_server();
    215 
    216         if ( method_exists( $server, 'get_compact_response_links' ) ) {
    217             $links = call_user_func( array( $server, 'get_compact_response_links' ), $response );
    218         } else {
    219             $links = call_user_func( array( $server, 'get_response_links' ), $response );
    220         }
     215        $links  = $server->get_compact_response_links( $response );
    221216
    222217        if ( ! empty( $links ) ) {
Note: See TracChangeset for help on using the changeset viewer.