* Setup: fix failed/partial restores for charsets not utf-8

caused by NULL converted to "" (empty string)
This commit is contained in:
Ralf Becker 2019-02-28 09:32:19 +01:00
parent 75fa8f4d05
commit 605e49579f

View File

@ -851,10 +851,14 @@ class Translation
* @param string|boolean $from charset $data is in or False if it should be detected
* @param string|boolean $to charset to convert to or False for the system-charset the converted string
* @param boolean $check_to_from =true internal to bypass all charset replacements
* @return string|array converted string(s) from $data
* @return NULL|string|array converted string(s) from $data
*/
static function convert($data,$from=False,$to=False,$check_to_from=true)
{
if (empty($data))
{
return $data; // no need for any charset conversation (NULL, '', 0, '0', array())
}
if ($check_to_from)
{
if ($from) $from = strtolower($from);
@ -925,7 +929,8 @@ class Translation
{
foreach($data as $key => $str)
{
$ret[$key] = self::convert($str,$from,$to,false); // false = bypass the above checks, as they are already done
$ret[$key] = empty($str) ? $str : // do NOT convert null to '' (other empty values need no conversation too)
self::convert($str,$from,$to,false); // false = bypass the above checks, as they are already done
}
return $ret;
}