5.x: deprecated mb_encode_mimeheader() usage
Description
My logs are filling up with errors:
mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead
Trace:
Cake\Error\ErrorTrap->handleError() [internal], line ??
/var/www/app/vendor/symfony/polyfill-mbstring/Mbstring.php /var/www/app/vendor/symfony/polyfill-mbstring/Mbstring.php, line 152
Symfony\Polyfill\Mbstring\Mbstring::mb_encode_mimeheader() /var/www/app/vendor/symfony/polyfill-mbstring/bootstrap80.php, line 21
/var/www/app/vendor/cakephp/cakephp/src/Mailer/Message.php /var/www/app/vendor/cakephp/cakephp/src/Mailer/Message.php, line 1764
Cake\Mailer\Message->encodeForHeader() /var/www/app/vendor/cakephp/cakephp/src/Mailer/Message.php, line 815
Symfony polyfill seems to cause this with
public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
{
trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING);
}
Message::encodeForHeader() is using it apparently:
$restore = mb_internal_encoding();
mb_internal_encoding($this->appCharset);
$return = mb_encode_mimeheader($text, $this->getHeaderCharset(), 'B');
mb_internal_encoding($restore);
CakePHP Version
5.2
PHP Version
8.3
Wow, I found https://github.com/cakephp/cakephp/issues/8511 Apparently we didnt do much here yet.
Apparently we didnt do much here yet.
do you have the mbstring extension installed? In the past that helped resolve this warning. Using iconv_mime_encode adds a new extension requirement (iconv), so it may not be a trivial fix.
Afaik /etc/php/8.3/fpm/conf.d/20-mbstring.ini was definitly loaded.
Couldnt the extension be optional and in that case it still can fallback to the "old way"? But that way it would be able to use the new way if available.
Also, we could detect if the method is available, .e.g. also via https://symfony.com/doc/2.x/components/polyfill_iconv.html and prefer that method over the buggy one I guess.
This seems like a polyfill error not a cake error.