Make WordPress Core

Opened 4 months ago

Closed 4 months ago

#60823 closed defect (bug) (fixed)

Font Library: `mb_strtolower()` throws fatal without the optional `mbstring` PHP extension installed.

Reported by: peterwilsoncc's profile peterwilsoncc Owned by: swissspidy's profile swissspidy
Milestone: 6.5 Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch commit fixed-major dev-reviewed
Focuses: Cc:

Description

WP_Font_Utils::get_font_face_slug() method includes an unconditional call to the function mb_strtolower().

As the mbstring PHP package is optional this should be wrapped by a function_exists() check and fall back to strtolower() if the function is not available.

  1. Visit https://playground.wordpress.net/?wp=nightly
  2. Click Edit Site in the toolbar
  3. Proceed to open the Font Library Model via the styles editor
  4. Open the browser console
  5. Upload a font file (that playground doesn't upload doesn't matter)
  6. Observe the fatal error shown in the console:
PHP Fatal error:  Uncaught Error: Call to undefined function mb_strtolower() in /wordpress/wp-includes/fonts/class-wp-font-utils.php

Change History (9)

#1 @jrf
4 months ago

Related: #55603

Last edited 4 months ago by SergeyBiryukov (previous) (diff)

This ticket was mentioned in Slack in #core-editor by peterwilsoncc. View the logs.


4 months ago

This ticket was mentioned in PR #6306 on WordPress/wordpress-develop by @mujuonly.


4 months ago
#3

  • Keywords has-patch added

Font Library: mb_strtolower() throws fatal without the optional mbstring PHP extension installed.

Trac ticket: https://core.trac.wordpress.org/ticket/60823

Reported by @peterwilsoncc

#4 @swissspidy
4 months ago

  • Focuses coding-standards removed
  • Keywords commit dev-feedback added

#5 @swissspidy
4 months ago

  • Owner set to swissspidy
  • Resolution set to fixed
  • Status changed from new to closed

In 57865:

Editor: Check if mb_strtolower exists before using it in the font library.

Prevents an error when uploading fonts on certain systems, because the mbstring extension can be missing and thus the function may not be available.

Props mujuonly, swissspidy, peterwilsoncc.
Fixes #60823.
See #55603.

#7 @swissspidy
4 months ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

#8 @jorbin
4 months ago

  • Keywords dev-reviewed added; dev-feedback removed

I've reviewed and tested. [57865] looks good for backport to the 6.5 branch.

#9 @swissspidy
4 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 57869:

Editor: Check if mb_strtolower exists before using it in the font library.

Prevents an error when uploading fonts on certain systems, because the mbstring extension can be missing and thus the function may not be available.

Reviewed by jorbin.
Merges [57865] to the to the 6.5 branch.

Props mujuonly, swissspidy, peterwilsoncc.
Fixes #60823.
See #55603.

Note: See TracTickets for help on using tickets.