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.

git-svn-id: https://develop.svn.wordpress.org/trunk@54813 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2022-11-11 15:26:59 +00:00
parent c3cd95732e
commit 9001cce4e0

View File

@ -1601,9 +1601,11 @@ function remove_accents( $string, $locale = '' ) {
// Unicode sequence normalization from NFD (Normalization Form Decomposed)
// to NFC (Normalization Form [Pre]Composed), the encoding used in this function.
if ( function_exists( 'normalizer_normalize' ) ) {
if ( ! normalizer_is_normalized( $string, Normalizer::FORM_C ) ) {
$string = normalizer_normalize( $string, Normalizer::FORM_C );
if ( function_exists( 'normalizer_is_normalized' )
&& function_exists( 'normalizer_normalize' )
) {
if ( ! normalizer_is_normalized( $string ) ) {
$string = normalizer_normalize( $string );
}
}