launchdarkly/php-server-sdk

utf8_encode is deprecated in PHP 8.2

malsatin opened this issue · 1 comments

Is this a support request?
No

Describe the bug
Functions utf8_encode and utf8_decode were deprecated in PHP 8.2.
This SDK uses utf8_encode in one of it's functions -

$cmd = base64_encode(iconv("UTF-8", "UTF-16LE", utf8_encode($args)));
which may produce deprecation warnings.

I suggest replacing iconv("UTF-8", "UTF-16LE", utf8_encode($args)) with mb_convert_encoding($args, 'UTF-16LE', 'ISO-8859-1')

To reproduce
Make sure, that error_reporting is set to E_ALL in php.ini and call CurlEventPublisher::publish() function

Expected behavior
No warnings and exceptions are produced

Logs
You will get exception Function utf8_encode() is deprecated depending on your php configuration and logs behavior

SDK version
v6.0.2

Language version, developer tools
PHP 8.3

OS/platform
Any

Additional context
This is preventing ticket, we don't use events sending and are not affected by that deprecation

I have merged a fix for this. It will go out in the next release (probably v6.1). Thank you so much for letting us know about this!