Make WordPress Core

Changeset 54814


Ignore:
Timestamp:
11/11/2022 03:29:13 PM (7 months ago)
Author:
SergeyBiryukov
Message:

Formatting: Check that both normalizer_* functions exist in remove_accents().

This applies to:

  • normalizer_is_normalized()
  • normalizer_normalize()

Includes removing the Normalizer::FORM_C constant as a parameter, since it is the default value for both functions and does not need to be explicitly passed. This avoids a fatal error if a plugin includes polyfill for any of the functions but the Normalizer class has a different namespace, for example when using the Symfony polyfill.

Follow-up to [53754].

Props hellofromTonya, costdev, desrosj, mukesh27, zodiac1978, jchambo, gisgeo, SergeyBiryukov.
Merges [54813] to the 6.1 branch.
Fixes #56980.

Location:
branches/6.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.1

  • branches/6.1/src/wp-includes/formatting.php

    r54482 r54814  
    16021602        // Unicode sequence normalization from NFD (Normalization Form Decomposed)
    16031603        // to NFC (Normalization Form [Pre]Composed), the encoding used in this function.
    1604         if ( function_exists( 'normalizer_normalize' ) ) {
    1605             if ( ! normalizer_is_normalized( $string, Normalizer::FORM_C ) ) {
    1606                 $string = normalizer_normalize( $string, Normalizer::FORM_C );
     1604        if ( function_exists( 'normalizer_is_normalized' )
     1605            && function_exists( 'normalizer_normalize' )
     1606        ) {
     1607            if ( ! normalizer_is_normalized( $string ) ) {
     1608                $string = normalizer_normalize( $string );
    16071609            }
    16081610        }
Note: See TracChangeset for help on using the changeset viewer.