-
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
Font Face: remove static instance in wp_print_font_faces() #54228
Font Face: remove static instance in wp_print_font_faces() #54228
Conversation
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.4/fonts/fonts.php |
Flaky tests detected in 5a80d93. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6100934090
|
The static instance of `WP_Font_Face` is not needed. It was an unnecessary carryover from the experimental Fonts API (which was not introduced into Core). Whereas the Fonts API needed to persist its data (i.e. to maintain the registered and enqueued fonts throughout the web request), Font Face does not have data to persist. Font Face processes the fonts it receives when `WP_Font_Face::generate_and_print( $fonts )` is invoked. Thus, a singleton is not needed. Removing the static reduces the amount of the code in the function and eliminates running its tests in separate processes to ensure a different instance is always used. References: * [WordPress/gutenberg#54228 Gutenberg PR 54228]. Follow-up to [56500]. Props hellofromTonya, costdev. Fixes #59165. git-svn-id: https://develop.svn.wordpress.org/trunk@56540 602fd350-edb4-49c9-b593-d223f7449a82
The static instance of `WP_Font_Face` is not needed. It was an unnecessary carryover from the experimental Fonts API (which was not introduced into Core). Whereas the Fonts API needed to persist its data (i.e. to maintain the registered and enqueued fonts throughout the web request), Font Face does not have data to persist. Font Face processes the fonts it receives when `WP_Font_Face::generate_and_print( $fonts )` is invoked. Thus, a singleton is not needed. Removing the static reduces the amount of the code in the function and eliminates running its tests in separate processes to ensure a different instance is always used. References: * [WordPress/gutenberg#54228 Gutenberg PR 54228]. Follow-up to [56500]. Props hellofromTonya, costdev. Fixes #59165. Built from https://develop.svn.wordpress.org/trunk@56540 git-svn-id: https://core.svn.wordpress.org/trunk@56052 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The static instance of `WP_Font_Face` is not needed. It was an unnecessary carryover from the experimental Fonts API (which was not introduced into Core). Whereas the Fonts API needed to persist its data (i.e. to maintain the registered and enqueued fonts throughout the web request), Font Face does not have data to persist. Font Face processes the fonts it receives when `WP_Font_Face::generate_and_print( $fonts )` is invoked. Thus, a singleton is not needed. Removing the static reduces the amount of the code in the function and eliminates running its tests in separate processes to ensure a different instance is always used. References: * [WordPress/gutenberg#54228 Gutenberg PR 54228]. Follow-up to [56500]. Props hellofromTonya, costdev. Fixes #59165. Built from https://develop.svn.wordpress.org/trunk@56540 git-svn-id: http://core.svn.wordpress.org/trunk@56052 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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 have reviewed the changes, and they seem safe to merge.
LGTM!
See WordPress Core WordPress/wordpress-develop#5159 and commit https://core.trac.wordpress.org/changeset/56540.
What?
Removes the static instance of
WP_Font_Face
fromwp_print_font_faces()
.Why?
This static is an unnecessary carryover from the Fonts API.
Whereas the Fonts API needed to persist its data (i.e. to maintain the registered and enqueued fonts throughout the web request), Font Face does not have data to persist.
Font Face processes the fonts it receives when
::generate_and_print( $fonts )
is invoked. Thus, a singleton is not needed.Removing the static reduces the amount of the code in the function and eliminates running its tests in separate processes to ensure a different instance is always used.
How?
Removes the static variable.
Instantiates a new instance each time the function is invoked.
Testing Instructions
There's no functionality changes.
All fonts tests and CI jobs should pass: