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. git-svn-id: https://develop.svn.wordpress.org/trunk@44173 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fb2f48d81b
commit
a376b4e284
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user