Fixed Re-implementation of /vendor/dokuwiki/utf8/utf8.php breaks things

Sim

Well-known member
Affected version
2.3.0
In v2.3.0 beta 6 I believe src/vendor/dokuwiki/utf8/utf8.php was replaced by src/utf8.php acting as a shim for the new XF\Util\Str functions.

The issue is that the way this has been implmented breaks certain systems - particularly my unit test framework - because it is simply "including" the file with no protection for redeclaration of functions contained within.

Please add protection from function redeclaration - as contained in the original src/vendor/dokuwiki/utf8/utf8.php

For example:

PHP:
if(!function_exists('utf8_isASCII')){
    function utf8_isASCII(string $str): string { return Str::is_ascii($str); }
}

I have verified that protecting the function declarations in this manner allows my unit test framework to operate as expected.
 
What specifically is failing? That function shouldn’t exist anyway, so why does it or what breaks as a result?
 
What specifically is failing? That function shouldn’t exist anyway, so why does it or what breaks as a result?

The unit test framework reinstantiates the XF App for every test, which results in utf8.php being included multiple times - thus attempting to redeclare the functions contained in it.

This is not something that should affect normal operation of the forum - it's specific to my use-case for unit testing.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.1).

Change log:
Do not attempt to redefine UTF-8 string shim functions if they already exist
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom