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

Correct the PHP version check for woff and woff2 MIME types. #59015

Conversation

costdev
Copy link
Contributor

@costdev costdev commented Feb 14, 2024

What?

In #58997, a bug was reported where fonts could not be installed in PHP 8.1.0 through 8.1.11 due to incorrect MIME type assignment. This PR corrects a PHP version check to resolve the issue.

Why?

While WP_Font_Utils::get_allowed_font_mime_types() conditionally sets the MIME type for woff and woff2, it incorrectly checks against PHP 8.1.0. The MIME type change did not occur until PHP 8.1.12.

See:

How?

This changes the checked PHP_VERSION_ID from 80100 to 80112 when choosing the correct MIME type for woff and woff2.

Testing Instructions

  1. Ensure that you are running a PHP version between PHP 8.1.0 and 8.1.11.
  2. Open the Site Editor.
  3. Navigate to Global Styles, then Typography.
  4. Click the button beside the Fonts heading.
  5. Navigate to the Install Fonts tab, and enable the connection to Google Fonts if requested.
  6. Click the first font in the list, check the boxes and click Install.
  7. 🐞 The installation will fail and the message will say that you can't upload a file of this type.
  8. Apply the PR.
  9. Repeat steps 2-7. The font should install without error. ✅

Copy link

github-actions bot commented Feb 14, 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.

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: costdev <costdev@git.wordpress.org>
Co-authored-by: hellofromtonya <hellofromtonya@git.wordpress.org>
Co-authored-by: huzaifaalmesbah <huzaifaalmesbah@git.wordpress.org>
Co-authored-by: kafleg <kafleg@git.wordpress.org>

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

@costdev costdev linked an issue Feb 14, 2024 that may be closed by this pull request
@costdev costdev added Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta [Feature] Font Library [Type] Bug An existing feature does not function as intended labels Feb 14, 2024
@hellofromtonya hellofromtonya requested review from hellofromtonya and removed request for spacedmonkey February 14, 2024 15:42
Copy link
Contributor

@hellofromtonya hellofromtonya left a comment

Choose a reason for hiding this comment

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

Yes indeed, PHP 8.1.12 is the version (not 8.1.00) that fixed the woff and woff2 file mime types. The changes are necessary.

@hellofromtonya
Copy link
Contributor

Excellent catch @costdev. Yes indeed, the version should be 8.1.12, as it's the first version that fixed the woff/woff2 mime types. Approved the PR ✅

Let's get this change sync'd back into Core too. Want to open a PR for it?

@hellofromtonya hellofromtonya merged commit 2822029 into WordPress:trunk Feb 14, 2024
62 of 64 checks passed
@github-actions github-actions bot added this to the Gutenberg 17.8 milestone Feb 14, 2024
@hellofromtonya hellofromtonya added the Backport to Gutenberg Minor Release Pull request that needs to be backported to a Gutenberg minor release label Feb 14, 2024
hellofromtonya added a commit to hellofromtonya/wordpress-develop that referenced this pull request Feb 14, 2024
Fixes a bug where fonts could not be installed in PHP 8.1.0 through 8.1.11 due to incorrect MIME type assignment.

While `WP_Font_Utils::get_allowed_font_mime_types()` conditionally sets the MIME type for woff and woff2, it incorrectly checks against PHP 8.1.0. The MIME type change did not occur until PHP 8.1.12.

References:

* PHP-src: finfo returns wrong mime type for woff/woff2 files php/php-src#8805
* PHP 8.1.12 changelog https://www.php.net/ChangeLog-8.php#8.1.12
* Tests: Adjust the expected mime type for WOFF fonts on PHP 8.1.12+ WordPress@5eefddf
* Gutenberg PR 59015 WordPress/gutenberg#59015

Props @costdev.
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Feb 14, 2024
Fixes a bug where fonts could not be installed in PHP 8.1.0 through 8.1.11 due to incorrect MIME type assignment.

While `WP_Font_Utils::get_allowed_font_mime_types()` conditionally sets the MIME type for woff and woff2, it incorrectly checks against PHP 8.1.0. The MIME type change did not occur until PHP 8.1.12.

References:

* [php/php-src#8805 PHP-src: finfo returns wrong mime type for woff/woff2 files].
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog].
* Tests: Adjust the expected mime type for WOFF fonts on PHP 8.1.12+ [55463].
* [WordPress/gutenberg#59015 Gutenberg PR 59015].

Follow-up to [57539].

Props costdev, kafleg, hellofromTonya.
Fixes 60536.

git-svn-id: https://develop.svn.wordpress.org/trunk@57632 602fd350-edb4-49c9-b593-d223f7449a82
@hellofromtonya hellofromtonya removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Feb 14, 2024
@hellofromtonya
Copy link
Contributor

Fix synchronized into Core via https://core.trac.wordpress.org/changeset/57632

github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Feb 14, 2024
Fixes a bug where fonts could not be installed in PHP 8.1.0 through 8.1.11 due to incorrect MIME type assignment.

While `WP_Font_Utils::get_allowed_font_mime_types()` conditionally sets the MIME type for woff and woff2, it incorrectly checks against PHP 8.1.0. The MIME type change did not occur until PHP 8.1.12.

References:

* [php/php-src#8805 PHP-src: finfo returns wrong mime type for woff/woff2 files].
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog].
* Tests: Adjust the expected mime type for WOFF fonts on PHP 8.1.12+ [55463].
* [WordPress/gutenberg#59015 Gutenberg PR 59015].

Follow-up to [57539].

Props costdev, kafleg, hellofromTonya.
Fixes 60536.
Built from https://develop.svn.wordpress.org/trunk@57632


git-svn-id: https://core.svn.wordpress.org/trunk@57133 1a063a9b-81f0-0310-95a4-ce76da25c4cd
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Feb 14, 2024
Fixes a bug where fonts could not be installed in PHP 8.1.0 through 8.1.11 due to incorrect MIME type assignment.

While `WP_Font_Utils::get_allowed_font_mime_types()` conditionally sets the MIME type for woff and woff2, it incorrectly checks against PHP 8.1.0. The MIME type change did not occur until PHP 8.1.12.

References:

* [php/php-src#8805 PHP-src: finfo returns wrong mime type for woff/woff2 files].
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog].
* Tests: Adjust the expected mime type for WOFF fonts on PHP 8.1.12+ [55463].
* [WordPress/gutenberg#59015 Gutenberg PR 59015].

Follow-up to [57539].

Props costdev, kafleg, hellofromTonya.
Fixes 60536.
Built from https://develop.svn.wordpress.org/trunk@57632


git-svn-id: http://core.svn.wordpress.org/trunk@57133 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@tellthemachines tellthemachines removed the Backport to Gutenberg Minor Release Pull request that needs to be backported to a Gutenberg minor release label Mar 4, 2024
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.

Installing Google font error - No font faces were installed.
3 participants