Normalize class

Warning: Cannot declare class Normalizer, because the name is already in use in /data/vhosts/elica-webservices.it/httpdocs/wp-content/plugins/cloudflare/vendor/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php on line 20

I am using CloudFlare plugin by CloudFlare themselves on CP - it worked like a charm. Recently it got TWO updates in a matter of hours and now I have this error in the logs.

I think they introduced this class and now it clashes with something else (not the theme - tried to revert to default activating The ClassicPress Theme and it’s still there).
It’s not a plugin conflict either (deactivated all of them except for the CloudFlare one and still there too).

So I guess that the Normalize class is used in core correct? This means I have to contact CloudFlare support and warn them they can’t use it because it clashes?

What if I just change that class in the plugin? I however will have to basically fork it to avoid losing my changes in it and then keep maintaining the fork by backporting CloudFlare updates…

While I was pondering I tried AI (Perplexity) and that means that I now know where core uses the class and it happens to be that WP and CP use the same class.
Cloudflare now includes polyfill-intl-normalizer that declares tha class too. The class is first loaded by WP/CP correctly and then when plugin tries to load it again the error occurs.
I will use this snippet in my functions.php file:

add_action(‘plugins_loaded’, function() {
if (class_exists(‘Normalizer’) && !class_exists(‘Symfony\Polyfill\Intl\Normalizer\Normalizer’, false)) {
// Skip polyfill load if native exists
remove_action(‘cloudflare_polyfill_load’, ‘load_symfony_normalizer’); // Adjust hook if needed
}
}, 5);

and contact them to let them know they need to release an update again.

1 Like