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 Face: remove static instance in wp_print_font_faces() #54228

Merged
merged 1 commit into from Sep 7, 2023

Conversation

hellofromtonya
Copy link
Contributor

@hellofromtonya hellofromtonya commented Sep 6, 2023

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 from wp_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:

npm run test:unit:php:base -- --group fonts

@github-actions
Copy link

github-actions bot commented Sep 6, 2023

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

@hellofromtonya hellofromtonya added [Type] Code Quality Issues or PRs that relate to code quality [Feature] Typography Font and typography-related issues and PRs Needs PHP backport Needs PHP backport to Core labels Sep 6, 2023
@hellofromtonya hellofromtonya self-assigned this Sep 6, 2023
@github-actions
Copy link

github-actions bot commented Sep 6, 2023

Flaky tests detected in 5a80d93.
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/6100934090
📝 Reported issues:

@hellofromtonya hellofromtonya enabled auto-merge (squash) September 7, 2023 17:24
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Sep 7, 2023
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
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Sep 7, 2023
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
markjaquith pushed a commit to WordPress/WordPress that referenced this pull request Sep 7, 2023
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
Copy link
Contributor

@anton-vlasenko anton-vlasenko left a 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!

@hellofromtonya hellofromtonya merged commit 98b331e into trunk Sep 7, 2023
53 of 57 checks passed
@hellofromtonya hellofromtonya deleted the fix/remove-static-from-wp_print_font_faces branch September 7, 2023 18:18
@github-actions github-actions bot added this to the Gutenberg 16.7 milestone Sep 7, 2023
@SiobhyB SiobhyB removed the Needs PHP backport Needs PHP backport to Core label Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Typography Font and typography-related issues and PRs [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants