Bug #81011 [NEW]: mb_convert_encoding removes array alements

From: Date: Tue, 04 May 2021 13:04:20 +0000
Subject: Bug #81011 [NEW]: mb_convert_encoding removes array alements
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233675@lists.php.net to get a copy of this message
From: mvalihora at gmail dot com Operating system: All PHP version: 7.4.18 Package: mbstring related Bug Type: Bug Bug description:mb_convert_encoding removes array alements Description: ------------ when some elements in array are changed by reference and this array is then converted using mb_convert_encoding, these elements are removed or empty. Warning is emmited "mb_convert_encoding(): Object is not supported in ...", but function returns result without mentioned elements. Best see in code example. Test script: --------------- // any sample array, structure does not matter $array = [ 'ads' => [ 123 => ['name' => 'this', 'id' => 444], 234 => ['name' => 'that', 'id' => 555], ], 'other' => ['one', 'two'] ]; // we modify array elements using reference foreach( $array['ads'] as &$ad ){ $ad['premium'] = (int)($ad['id'] == 555); } // print_r prints array contents OK print_r($array); // mb_convert_encoding emits Warning, but returns result where modified array elements are removed - in this case 'ads' element print_r(mb_convert_encoding($array, 'UTF-8', 'UTF-8')); Expected result: ---------------- array elements does not disappear, mb_convert_encoding does not emit warning Actual result: -------------- mb_convert_encoding returns result where modified array elements are removed. mb_convert_encoding emits warning -- Edit bug report at https://bugs.php.net/bug.php?id=81011&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81011&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81011&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81011&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81011&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81011&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81011&r=support Expected behavior: https://bugs.php.net/fix.php?id=81011&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81011&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81011&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81011&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81011&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81011&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81011&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81011&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81011&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81011&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81011&r=mysqlcfg

« previous php.bugs (#233675) next »