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.

Props schlessera, timothyblynjacobs.
Fixes #45189.

Built from https://develop.svn.wordpress.org/branches/5.0@43834


git-svn-id: http://core.svn.wordpress.org/branches/5.0@43663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
danielbachhuber 2018-10-29 00:49:40 +00:00
parent eea6942164
commit 7136636db3
3 changed files with 3 additions and 12 deletions

View File

@ -1368,11 +1368,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;
}

View File

@ -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;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.0-beta1-43833';
$wp_version = '5.0-beta1-43834';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.