-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/55278 standardize font library rest api #55454
Conversation
…ated collection IDs
Warning: Type of PR label error To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. |
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/experimental/fonts/font-library/class-wp-rest-font-collections-controller.php ❔ lib/experimental/fonts/font-library/class-wp-rest-font-families-controller.php ❔ phpunit/data/fonts/DMSans.woff2 ❔ phpunit/data/fonts/Merriweather.ttf ❔ phpunit/data/fonts/cooper-hewitt.woff ❔ phpunit/data/fonts/gilbert-color.otf ❔ phpunit/tests/fonts/font-library/wpFontCollection/registerFontCollection.php ❔ phpunit/tests/fonts/font-library/wpRestFontCollectionController/wpRestFontCollectionsController.php ❔ phpunit/tests/fonts/font-library/wpRestFontFamiliesController/base.php ❔ phpunit/tests/fonts/font-library/wpRestFontFamiliesController/createItem.php ❔ phpunit/tests/fonts/font-library/wpRestFontFamiliesController/deleteItem.php ❔ phpunit/tests/fonts/font-library/wpRestFontFamiliesController/getItem.php ❔ phpunit/tests/fonts/font-library/wpRestFontFamiliesController/getItems.php ❔ phpunit/tests/fonts/font-library/wpRestFontFamiliesController/registerRoutes.php ❔ lib/experimental/fonts/font-library/class-wp-font-family.php ❔ lib/experimental/fonts/font-library/class-wp-font-library.php ❔ lib/experimental/fonts/font-library/font-library.php ❔ lib/load.php ❔ phpunit/tests/fonts/font-library/wpFontCollection/__construct.php ❔ phpunit/tests/fonts/font-library/wpFontCollection/getData.php ❔ phpunit/tests/fonts/font-library/wpFontFamily/uninstall.php ❔ phpunit/tests/fonts/font-library/wpFontLibrary/registerFontCollection.php ❔ phpunit/tests/fonts/font-library/wpFontCollection/getFontCollection.php ❔ phpunit/tests/fonts/font-library/wpFontCollection/getFontCollections.php ❔ phpunit/tests/fonts/font-library/wpRestFontCollectionController/base.php |
Size Change: -74 B (0%) Total Size: 1.66 MB
ℹ️ View Unchanged
|
Flaky tests detected in 329ee7d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6562783153
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial thoughts based on a cursory review
lib/experimental/fonts/font-library/class-wp-rest-font-collections-controller.php
Outdated
Show resolved
Hide resolved
lib/experimental/fonts/font-library/class-wp-rest-font-collections-controller.php
Outdated
Show resolved
Hide resolved
lib/experimental/fonts/font-library/class-wp-rest-font-collections-controller.php
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,300 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file needs some tests for the unauthenticated and unauthorized scenarios.
.../tests/fonts/font-library/wpRestFontCollectionController/wpRestFontCollectionsController.php
Outdated
Show resolved
Hide resolved
* | ||
* @covers WP_REST_Font_Families_Controller::delete_item | ||
*/ | ||
class Tests_Fonts_WPRESTFontFamiliesController_DeleteItem extends WP_REST_Font_Families_Controller_UnitTestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we consolidate these Tests_Fonts_WPRESTFontFamiliesController_*
test classes into one larger WP_Test_REST_Font_Families_Controller
class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we could... what's the benefit? The create_item
tests especially are pretty big and combining them into a single file seems unnecessary. Other tests in the suite are broken similarly. Would you want to consider consolidation of those too?
* @return WP_REST_Response|WP_Error The updated Font Library post content. | ||
*/ | ||
public function create_item( $request ) { | ||
$font_family_data = array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What sort of validation/sanitization do these request arguments need?
lib/experimental/fonts/font-library/class-wp-rest-font-families-controller.php
Outdated
Show resolved
Hide resolved
); | ||
|
||
if ( $request->get_param( 'fontFace' ) ) { | ||
$font_family_data['fontFace'] = json_decode( $request->get_param( 'fontFace' ), true ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What sort of validation/sanitization does this need?
closing in leu of #57688 |
What?
Fixes #55278
rest_ensure_response
for all API responsesWhy?
The original implementation was "non standard" in a number of ways (documented in #55278)
How?
Much of the work was previously accomplished during the attempt to merge this work into WordPress Core for the 6.4 release. Those changes have been ported here (as well as the view changes necessary).
Testing Instructions