From d45d54005a1c4318b9a6684962233b952e311210 Mon Sep 17 00:00:00 2001 From: Grant Kinney Date: Fri, 19 Jan 2024 16:16:36 -0600 Subject: [PATCH] Font Families and Faces: disable autosaves using empty class (#58018) --- ...lass-wp-rest-autosave-fonts-controller.php | 25 ------------------- .../fonts/font-library/font-library.php | 6 +++-- lib/load.php | 1 - .../wpRestFontFacesController.php | 16 ++++++++++++ .../wpRestFontFamiliesController.php | 16 ++++++++++++ 5 files changed, 36 insertions(+), 28 deletions(-) delete mode 100644 lib/experimental/fonts/font-library/class-wp-rest-autosave-fonts-controller.php diff --git a/lib/experimental/fonts/font-library/class-wp-rest-autosave-fonts-controller.php b/lib/experimental/fonts/font-library/class-wp-rest-autosave-fonts-controller.php deleted file mode 100644 index 8613a54cc3b1b4..00000000000000 --- a/lib/experimental/fonts/font-library/class-wp-rest-autosave-fonts-controller.php +++ /dev/null @@ -1,25 +0,0 @@ - true, 'rest_base' => 'font-families', 'rest_controller_class' => 'WP_REST_Font_Families_Controller', - 'autosave_rest_controller_class' => 'WP_REST_Autosave_Fonts_Controller', + // Disable autosave endpoints for font families. + 'autosave_rest_controller_class' => 'stdClass', ); register_post_type( 'wp_font_family', $args ); @@ -83,7 +84,8 @@ function gutenberg_init_font_library_routes() { 'show_in_rest' => true, 'rest_base' => 'font-families/(?P[\d]+)/font-faces', 'rest_controller_class' => 'WP_REST_Font_Faces_Controller', - 'autosave_rest_controller_class' => 'WP_REST_Autosave_Fonts_Controller', + // Disable autosave endpoints for font faces. + 'autosave_rest_controller_class' => 'stdClass', ) ); diff --git a/lib/load.php b/lib/load.php index 81daeef25933f3..e3b650a8afe28b 100644 --- a/lib/load.php +++ b/lib/load.php @@ -157,7 +157,6 @@ function gutenberg_is_experiment_enabled( $name ) { require __DIR__ . '/experimental/fonts/font-library/class-wp-rest-font-families-controller.php'; require __DIR__ . '/experimental/fonts/font-library/class-wp-rest-font-faces-controller.php'; require __DIR__ . '/experimental/fonts/font-library/class-wp-rest-font-collections-controller.php'; - require __DIR__ . '/experimental/fonts/font-library/class-wp-rest-autosave-fonts-controller.php'; require __DIR__ . '/experimental/fonts/font-library/font-library.php'; } diff --git a/phpunit/tests/fonts/font-library/wpRestFontFacesController.php b/phpunit/tests/fonts/font-library/wpRestFontFacesController.php index 55db0ce18392d1..1904a17228bdce 100644 --- a/phpunit/tests/fonts/font-library/wpRestFontFacesController.php +++ b/phpunit/tests/fonts/font-library/wpRestFontFacesController.php @@ -111,6 +111,22 @@ public function test_register_routes() { ); } + public function test_font_faces_no_autosave_routes() { + // @core-merge: Enable this test. + $this->markTestSkipped( 'This test only works with WP 6.4 and above. Enable it once 6.5 is released.' ); + $routes = rest_get_server()->get_routes(); + $this->assertArrayNotHasKey( + '/wp/v2/font-families/(?P[\d]+)/font-faces/(?P[\d]+)/autosaves', + $routes, + 'Font faces autosaves route exists.' + ); + $this->assertArrayNotHasKey( + '/wp/v2/font-families/(?P[\d]+)/font-faces/(?P[\d]+)/autosaves/(?P[\d]+)', + $routes, + 'Font faces autosaves by id route exists.' + ); + } + /** * @covers WP_REST_Font_Faces_Controller::get_context_param */ diff --git a/phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php b/phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php index 4fffa879ad56ed..6e6a822a9881fb 100644 --- a/phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php +++ b/phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php @@ -126,6 +126,22 @@ public function test_register_routes() { ); } + public function test_font_families_no_autosave_routes() { + // @core-merge: Enable this test. + $this->markTestSkipped( 'This test only works with WP 6.4 and above. Enable it once 6.5 is released.' ); + $routes = rest_get_server()->get_routes(); + $this->assertArrayNotHasKey( + '/wp/v2/font-families/(?P[\d]+)/autosaves', + $routes, + 'Font families autosaves route exists.' + ); + $this->assertArrayNotHasKey( + '/wp/v2/font-families/(?P[\d]+)/autosaves/(?P[\d]+)', + $routes, + 'Font families autosaves by id route exists.' + ); + } + /** * @covers WP_REST_Font_Families_Controller::get_context_param */