From d2782aabc51f387c405eacc2ddbd38dfdacd4405 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 14 Dec 2018 06:04:55 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@44173 git-svn-id: http://core.svn.wordpress.org/trunk@44003 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api.php | 6 +----- .../rest-api/endpoints/class-wp-rest-controller.php | 7 +------ wp-includes/version.php | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php index 26593af44a..1c8bb4620e 100644 --- a/wp-includes/rest-api.php +++ b/wp-includes/rest-api.php @@ -1367,11 +1367,7 @@ function rest_preload_api_request( $memo, $path ) { if ( 200 === $response->status ) { $server = rest_get_server(); $data = (array) $response->get_data(); - if ( method_exists( $server, 'get_compact_response_links' ) ) { - $links = call_user_func( array( $server, 'get_compact_response_links' ), $response ); - } else { - $links = call_user_func( array( $server, 'get_response_links' ), $response ); - } + $links = $server->get_compact_response_links( $response ); if ( ! empty( $links ) ) { $data['_links'] = $links; } diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-controller.php index dbd129cc43..389262274f 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-controller.php @@ -212,12 +212,7 @@ abstract class WP_REST_Controller { $data = (array) $response->get_data(); $server = rest_get_server(); - - if ( method_exists( $server, 'get_compact_response_links' ) ) { - $links = call_user_func( array( $server, 'get_compact_response_links' ), $response ); - } else { - $links = call_user_func( array( $server, 'get_response_links' ), $response ); - } + $links = $server->get_compact_response_links( $response ); if ( ! empty( $links ) ) { $data['_links'] = $links; diff --git a/wp-includes/version.php b/wp-includes/version.php index 064e93f8c5..3a0b603c76 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.1-alpha-44172'; +$wp_version = '5.1-alpha-44173'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.