Skip to content
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

Font Library: Do not register the google fonts collection if already registered #58769

Merged
merged 5 commits into from
Feb 7, 2024

Conversation

youknowriad
Copy link
Contributor

What?

In order to test this properly, you'll have to run this PR on top of the following Core patch WordPress/wordpress-develop#6056

You shouldn't see any error due to "double registration of google-fonts" collection.

This PR is blocking the introduction of the google fonts collection into Core.

@youknowriad youknowriad self-assigned this Feb 7, 2024
@youknowriad youknowriad added the [Type] Bug An existing feature does not function as intended label Feb 7, 2024
Copy link

github-actions bot commented Feb 7, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core SVN

Core Committers: Use this line as a base for the props when committing in SVN:

Props youknowriad, get_dave, mmaattiiaass.

GitHub Merge commits

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: matiasbenedetto <mmaattiiaass@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

github-actions bot commented Feb 7, 2024

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/compat/wordpress-6.5/fonts/fonts.php
❔ phpunit/tests/fonts/font-library/wpRestFontCollectionsController.php

@youknowriad
Copy link
Contributor Author

Looks like there's some php unit test failures 🤔

@youknowriad
Copy link
Contributor Author

@matiasbenedetto any idea what's happening with the php test failures here?

@getdave
Copy link
Contributor

getdave commented Feb 7, 2024

Rest server has not the collections path initialized.

This error message also needs grammar updating to

Rest server does not have the collections path initialized.

@matiasbenedetto
Copy link
Contributor

Failed asserting that actual size 2 matches expected size 1.

It seems like the /font-collections/ rest API endpoint is repeated.

This is the assertion failing:

$this->assertCount( 1, $routes['/wp/v2/font-collections'], 'Rest server has not the collections path initialized.' );

It seems unrelated to this PR and produced by the double registration of the font collection endpoint (in core and in the plugin).
We would need to add some conditional to these lines in the plugin:

*/
function gutenberg_init_font_library() {
gutenberg_create_initial_post_types();
gutenberg_create_initial_rest_routes();
}

@youknowriad
Copy link
Contributor Author

It seems that the practice for other endpoints has been to double the expect call in the tests. So I did that in the last commit. I think personally that we could consider removing this kind of assertions entirely, but let's leave that separate.

@youknowriad
Copy link
Contributor Author

Actually, I just went ahead and removed these two assertions from this test.

@matiasbenedetto
Copy link
Contributor

Now the Rest API is merged into core, could we remove the tests for the font library rest API endpoints entirely?

@youknowriad
Copy link
Contributor Author

@matiasbenedetto I think so yes, since the class being tests is actually the one in Core (due to the class_exists check), but let's do that in its own PR.

Copy link
Contributor

@matiasbenedetto matiasbenedetto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@youknowriad youknowriad enabled auto-merge (squash) February 7, 2024 13:48
@youknowriad youknowriad merged commit f5d3cbf into trunk Feb 7, 2024
57 checks passed
@youknowriad youknowriad deleted the fix/double-google-font-registration branch February 7, 2024 13:50
@github-actions github-actions bot added this to the Gutenberg 17.7 milestone Feb 7, 2024
youknowriad added a commit that referenced this pull request Feb 7, 2024
…registered (#58769)

Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: matiasbenedetto <mmaattiiaass@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Font Library [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants