diff options
author | William Desportes <williamdes@wdes.fr> | 2019-05-01 18:05:35 +0300 |
---|---|---|
committer | William Desportes <williamdes@wdes.fr> | 2019-05-01 18:07:03 +0300 |
commit | 8b7db3bd5b6ab93e7fd31125d2d113021bd803fc (patch) | |
tree | 528d2874c9b5e279d44e1dc218484c9953bf59f3 | |
parent | 4909352c8840399fbfd4137796f5cc1890971be8 (diff) | |
parent | eca65975b3a54f36c59c6152f3a7559c83f6efe0 (diff) |
Fix #15059 - Server charset hardcoded in index.php
Fixes: #15059
Pull-request: #15103
Signed-off-by: William Desportes <williamdes@wdes.fr>
-rw-r--r-- | index.php | 6 | ||||
-rw-r--r-- | libraries/classes/Charsets.php | 25 |
2 files changed, 29 insertions, 2 deletions
@@ -369,12 +369,14 @@ if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) { echo ' <li id="li_select_mysql_charset">'; echo ' ' , __('Server charset:') , ' ' . ' <span lang="en" dir="ltr">'; - $unicode = Charsets::$mysql_charset_map['utf-8']; + + $charset = Charsets::getServerCharset($GLOBALS['dbi']); $charsets = Charsets::getMySQLCharsetsDescriptions( $GLOBALS['dbi'], $GLOBALS['cfg']['Server']['DisableIS'] ); - echo ' ' , $charsets[$unicode], ' (' . $unicode, ')'; + + echo ' ' , $charsets[$charset], ' (' . $charset, ')'; echo ' </span>' . ' </li>' . ' </ul>' diff --git a/libraries/classes/Charsets.php b/libraries/classes/Charsets.php index 4f73e0eed8..c01159271d 100644 --- a/libraries/classes/Charsets.php +++ b/libraries/classes/Charsets.php @@ -49,6 +49,14 @@ class Charsets ); private static $_charsets = array(); + + /** + * The charset for the server + * + * @var string + */ + private static $_charset_server; + private static $_charsets_descriptions = array(); private static $_collations = array(); private static $_default_collations = array(); @@ -127,6 +135,23 @@ class Charsets } } + /** + * Get current MySQL server charset. + * + * @param DatabaseInterface $dbi DatabaseInterface instance + * + * @return string + */ + public static function getServerCharset(DatabaseInterface $dbi) + { + if (self::$_charset_server) { + return self::$_charset_server; + } else { + self::$_charset_server = $dbi->getVariable('character_set_server'); + return self::$_charset_server; + } + } + /** * Get MySQL charsets * |