From 2c71852545033e33b0b8613c19885df652e2ffff Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 8 Dec 2014 19:16:44 +0000 Subject: [PATCH] fix for php 5.6+ deprecating mbstring.internal_encoding in favor or default_charset --- phpgwapi/inc/class.db_backup.inc.php | 3 ++- phpgwapi/inc/class.translation.inc.php | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/phpgwapi/inc/class.db_backup.inc.php b/phpgwapi/inc/class.db_backup.inc.php index 9bc4563fc8..51a66245b3 100644 --- a/phpgwapi/inc/class.db_backup.inc.php +++ b/phpgwapi/inc/class.db_backup.inc.php @@ -532,7 +532,8 @@ class db_backup { $charset = trim(substr($line,9)); // needed if mbstring.func_overload > 0, else eg. substr does not work with non ascii chars - @ini_set('mbstring.internal_encoding',$charset); + $ini_default_charset = version_compare(PHP_VERSION, '5.6', '<') ? 'mbstring.internal_encoding' : 'default_charset'; + @ini_set($ini_default_charset, $charset); // check if we really need to convert the charset, as it's not perfect and can do some damage if ($convert_to_system_charset && !strcasecmp($this->schema_proc->system_charset, $charset)) diff --git a/phpgwapi/inc/class.translation.inc.php b/phpgwapi/inc/class.translation.inc.php index a8c59183b1..2d35cb746b 100644 --- a/phpgwapi/inc/class.translation.inc.php +++ b/phpgwapi/inc/class.translation.inc.php @@ -86,11 +86,11 @@ class translation */ static $mbstring; /** - * Internal encoding / charset of mbstring (if loaded) + * Internal encoding / charset of PHP / mbstring (if loaded) * * @var string */ - static $mbstring_internal_encoding; + static $default_charset; /** * Application which translations have to be cached instance- and NOT tree-specific @@ -138,9 +138,10 @@ class translation // we need to set our charset as mbstring.internal_encoding if mbstring.func_overlaod > 0 // else we get problems for a charset is different from the default utf-8 - if (ini_get('mbstring.func_overload') && self::$mbstring_internal_encoding != $charset) + $ini_default_charset = version_compare(PHP_VERSION, '5.6', '<') ? 'mbstring.internal_encoding' : 'default_charset'; + if (ini_get($ini_default_charset) && self::$default_charset != $charset) { - ini_set('mbstring.internal_encoding',self::$mbstring_internal_encoding = $charset); + ini_set($ini_default_charset, self::$default_charset = $charset); } return $charset; }