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: Avoid running init functions when font library is available in core. #58793

Merged
merged 6 commits into from
Feb 8, 2024

Conversation

matiasbenedetto
Copy link
Contributor

What?

Avoid running init functions from the plugin when the font library is available in core.

Why?

  • Avoid creating repeated endpoints.
    If the Gutenberg plugin is installed on WordPress core trunk (6.5-alpha) the font collection endpoints are created twice each, one by core and one by the plugin. This PR avoids that.

How?

Checking the WordPress version before running the endpoints creation function.
If the WordPress core version is < 6.5-alpha, the font collection endpoints are not created by the Gutenberg plugin.

Testing Instructions

  • Install and activate this Gutenberg PR on WordPress core trunk version.
  • Check that the /font-collections/ and /font-collections/<slug> endpoints are not repeated.
  • Check that the font collections load as expected.
  • Install and activate this Gutenberg PR on WordPress 6.4.3 version.
  • Check that the /font-collections/ and /font-collections/<slug> endpoints are not repeated.
  • Check that the font collections load as expected.

…es only if the WP_Font_Library class is not available, for example when the plugin run on WordPress < 6.5
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 mmaattiiaass, youknowriad.

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: matiasbenedetto <mmaattiiaass@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>

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

@matiasbenedetto matiasbenedetto added [Type] Bug An existing feature does not function as intended [Feature] Font Library labels Feb 7, 2024
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

Copy link

github-actions bot commented Feb 7, 2024

Flaky tests detected in 20693ca.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7820836576
📝 Reported issues:

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

I agree that this is something we could do. It will clarify that any changes to the controller for future versions need to happen on a new compat/wordpress-6.6 instead.

But I'd like to note also that most other controllers that were added to Gutenberg were actually being registered twice during that transition period.

@matiasbenedetto matiasbenedetto merged commit 11fe025 into trunk Feb 8, 2024
57 checks passed
@matiasbenedetto matiasbenedetto deleted the add/conditional-init-font-library branch February 8, 2024 12:32
@github-actions github-actions bot added this to the Gutenberg 17.7 milestone Feb 8, 2024
@desrosj
Copy link
Contributor

desrosj commented Feb 8, 2024

👋 Hi @matiasbenedetto! Just a friendly reminder to manually review, update as needed, and include the Co-authored-by trailers in the merge commit message. In case it was missed, here's the announcement post and the accompanying handbook page with the specific details.

If it was on accident, no big deal! But just trying to make sure everyone is aware as we retrain our brains. 😄

@matiasbenedetto
Copy link
Contributor Author

Hi @desrosj, yep, sorry I did that on several PRs, but I forgot to do that on others; my bad.
I have 2 questions:

  1. Is it possible to fix the error on an already merged PR?
  2. Is it possible to automate the inclusion of the new Co-authored-by credits automatically on the merge commits messages? that would be very useful.

@desrosj
Copy link
Contributor

desrosj commented Feb 9, 2024

@matiasbenedetto There's no way to go back and change the commit message without changing the commit SHA and breaking things. But, in the long scheme of a release, that's OK. As long as everyone that contributed has other credits in the release! The overall counts for contributions are not a huge deal and being off by one or two is ok.

The process cannot be 100% automated for a few reasons. But mainly, if it were fully automated we would potentially incentivize behavior that we do not want to see, ie. commenting on lots of issues just to accumulate lots of credits. It also would not give the opportunity for someone to add a contributor who did not directly interact in GitHub. Maybe a designer, or someone that gave important feedback during a Slack conversation.

The goal is to make this as friction-less as possible, but some level of human interaction is necessary. If you have ideas how to further improve the process, please do share them in the https://github.com/WordPress/props-bot-action/ repo. We've already implemented several suggestions in the short week since the tool was merged!

@matiasbenedetto
Copy link
Contributor Author

Thanks for the detailed answer

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