From fb913af813ba32cc4ef0bd22e58016477aed607a Mon Sep 17 00:00:00 2001 From: Matias Benedetto Date: Wed, 23 Aug 2023 15:07:54 -0300 Subject: [PATCH] reuse WP_Error response instead of creating a new one Co-authored-by: Tonya Mork --- .../font-library/class-wp-rest-font-library-controller.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/experimental/fonts/font-library/class-wp-rest-font-library-controller.php b/lib/experimental/fonts/font-library/class-wp-rest-font-library-controller.php index 4208684fedd68a..2bf1c9dd671489 100644 --- a/lib/experimental/fonts/font-library/class-wp-rest-font-library-controller.php +++ b/lib/experimental/fonts/font-library/class-wp-rest-font-library-controller.php @@ -106,11 +106,7 @@ public function get_font_collection( $request ) { $collection = WP_Font_Library::get_font_collection( $id ); if ( is_wp_error( $collection ) ) { - return new WP_Error( - 'font_collection_not_found', - __( 'Font collection not found.', 'gutenberg' ), - array( 'status' => 404 ) - ); + return $collection; } return new WP_REST_Response( $collection->get_data() );