Closed alsar closed 6 years ago
Thanks for reporting this, the lib was really missing. The implementation and the version will still be missing despite the fix but you can validate that it's working now by running the following snippet in the container as suggested in https://github.com/docker-library/php/issues/240#issuecomment-306246179
php -d error_reporting=22527 -d display_errors=1 -r 'var_dump(iconv("UTF-8", "UTF-8//IGNORE", "This is the Euro symbol '\''€'\''."));'
If it runs without notices it's all good.
It works now. Thank you for the quick fix.
@csandanov The fix works with the CLI but not with FPM.
CLI environment variables from phpinfo():
LD_PRELOAD => /usr/lib/preloadable_libiconv.so php
$_SERVER['LD_PRELOAD'] => /usr/lib/preloadable_libiconv.so php
$_ENV['LD_PRELOAD'] => /usr/lib/preloadable_libiconv.so php
But those variables are missing when I output phpinfo() with FPM.
Yes, that's because FPM has clear_env = yes
by default. Added LD_PRELOAD
to the list of env vars that always pass through.
I tried the updated image. The environment variables are now present, but the iconv function with translit still fails with FPM.
Does it work if you set clear_env = yes
and LD_PRELOAD=/usr/lib/preloadable_libiconv.so php-fpm
?
No. The change is visible in php.ini, but it still works only for CLI but not FPM.
Right, we run fpm via sudo. Added LD_PRELOAD
directly to the command, my example from above now runs without notices via fpm as well.
It works now. Thanks.
Just a remark. On my local setup the command php -r "var_dump(iconv('UTF-8', 'ASCII//TRANSLIT', 'tést'));"
outputs test
, but with your image it's t'est
.
Do you know maybe what is this related to? Locales maybe?
What's your OS? AFAIK, Linux and Windows use different libs for iconv
I'm on Linux. Ubuntu 16.04 with PHP 7.2.4 with glibc 2.23
Probably.
When I output setlocale(LC_ALL, 0);
I get:
on my local installation: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C
inside the container: C.UTF-8;C;C;C;C;C
I doubt this issue can be resolved, most likely this caused due to usage of GNU iconv library and not having a good locale support in musl, try using http://php.net/manual/en/transliterator.transliterate.php instead for transliteration:
php -r 'var_dump(transliterator_transliterate("Any-Latin; Latin-ASCII; [\u0080-\u7fff] remove", "A æ Übérmensch på høyeste nivå! И я люблю PHP! есть. fi ¦"));'
Fixed by installing php7-mbstring
php7-iconv
in that order
RUN apk --no-cache add php7-mbstring php7-iconv
Original solution here: https://github.com/docker-library/php/issues/240#issuecomment-355489551
Fixed in the upstream https://github.com/docker-library/php/pull/1264
The iconv extension is enabled, but there is no implementation available (like glibc). I tried with 7.2, 7.1 and 5.6 images.
The php.ini output:
As a result the iconv() function fails with translit:
iconv('utf-8', 'ascii//TRANSLIT', 'test');
Notice: iconv(): Wrong charset, conversion from 'utf-8' to 'ascii//TRANSLIT' is not allowed