From 12f596ceb203692673e37e2c7106a0dc0f80e824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 25 Nov 2016 15:41:40 +0100 Subject: [PATCH] Fix PHP error when mbstring is not installed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is still dependency for us, but we should be able to tell user nicely that it is missing. Fixes #12734 Signed-off-by: Michal Čihař --- ChangeLog | 1 + libraries/php-gettext/gettext.inc | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21c7e7a042..70fd6ad236 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ phpMyAdmin - ChangeLog 4.6.6 (not yet released) - issue #12735 Incorrect parameters to escapeString in Node.php +- issue #12734 Fix PHP error when mbstring is not installed 4.6.5 (2016-11-24) - issue Remove potentionally license problematic sRGB profile diff --git a/libraries/php-gettext/gettext.inc b/libraries/php-gettext/gettext.inc index 7b97b0d00d..22bd614013 100644 --- a/libraries/php-gettext/gettext.inc +++ b/libraries/php-gettext/gettext.inc @@ -166,17 +166,28 @@ function _check_locale_and_function($function=false) { */ function _get_codeset($domain=null) { global $text_domains, $default_domain, $LC_CATEGORIES; - if (!isset($domain)) $domain = $default_domain; - return (isset($text_domains[$domain]->codeset))? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding'); + if (!isset($domain)) { + $domain = $default_domain; + } + if (isset($text_domains[$domain]->codeset)) { + return $text_domains[$domain]->codeset; + } + if (!empty(ini_get('mbstring.internal_encoding'))) { + return ini_get('mbstring.internal_encoding'); + } + return 'utf-8'; } /** * Convert the given string to the encoding set by bind_textdomain_codeset. */ function _encode($text) { - $source_encoding = mb_detect_encoding($text); - if ($source_encoding === false) { - $source_encoding = 'utf-8'; + $source_encoding = 'utf-8'; + if (function_exists(mb_detect_encoding)) { + $source_encoding = mb_detect_encoding($text); + if ($source_encoding === false) { + $source_encoding = 'utf-8'; + } } $target_encoding = _get_codeset(); if ($source_encoding != $target_encoding) {