--- a/wp/wp-includes/rest-api/endpoints/class-wp-rest-controller.php Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/rest-api/endpoints/class-wp-rest-controller.php Tue Sep 27 16:37:53 2022 +0200
@@ -504,11 +504,14 @@
*
* @since 4.7.0
*
+ * @global array $wp_rest_additional_fields Holds registered fields, organized by object type.
+ *
* @param string $object_type Optional. The object type.
- * @return array Registered additional fields (if any), empty array if none or if the object type could
- * not be inferred.
+ * @return array Registered additional fields (if any), empty array if none or if the object type
+ * could not be inferred.
*/
protected function get_additional_fields( $object_type = null ) {
+ global $wp_rest_additional_fields;
if ( ! $object_type ) {
$object_type = $this->get_object_type();
@@ -518,8 +521,6 @@
return array();
}
- global $wp_rest_additional_fields;
-
if ( ! $wp_rest_additional_fields || ! isset( $wp_rest_additional_fields[ $object_type ] ) ) {
return array();
}
@@ -596,7 +597,7 @@
// Return the list of all requested fields which appear in the schema.
return array_reduce(
$requested_fields,
- function( $response_fields, $field ) use ( $fields ) {
+ static function( $response_fields, $field ) use ( $fields ) {
if ( in_array( $field, $fields, true ) ) {
$response_fields[] = $field;
return $response_fields;