Make WordPress Core

Changeset 54813


Ignore:
Timestamp:
11/11/2022 03:26:59 PM (2 years 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.
Fixes #56980.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r54663 r54813  
    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.