Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMA does not detect real server character set #13709

Closed
mlapkin opened this issue Sep 29, 2017 · 3 comments
Closed

PMA does not detect real server character set #13709

mlapkin opened this issue Sep 29, 2017 · 3 comments
Assignees
Labels
question Used when we need feedback from the submitter or when the issue is a question about PMA

Comments

@mlapkin
Copy link

mlapkin commented Sep 29, 2017

$unicode = Charsets::$mysql_charset_map['utf-8'];

Suddenly PMA always shows your server has UTF-8 character set by default even it isn't.

@nijel
Copy link
Contributor

nijel commented Oct 2, 2017

But phpMyAdmin configures the connection charset to utf-8, so this seems correct...

if ($this->_version_int > 50503) {
$default_charset = 'utf8mb4';
$default_collation = 'utf8mb4_general_ci';
} else {
$default_charset = 'utf8';
$default_collation = 'utf8_general_ci';
}
$collation_connection = $GLOBALS['PMA_Config']->get('collation_connection');
if (! empty($collation_connection)) {
$this->query(
"SET CHARACTER SET '$default_charset';",
$link,
self::QUERY_STORE
);
/* Automatically adjust collation if not supported by server */
if ($default_charset == 'utf8'
&& strncmp('utf8mb4_', $collation_connection, 8) == 0
) {
$collation_connection = 'utf8_' . substr($collation_connection, 8);
}
$result = $this->tryQuery(
"SET collation_connection = '"
. $this->escapeString($collation_connection, $link)
. "';",
$link,
self::QUERY_STORE
);
if ($result === false) {
trigger_error(
__('Failed to set configured collation connection!'),
E_USER_WARNING
);
$this->query(
"SET collation_connection = '"
. $this->escapeString($collation_connection, $link)
. "';",
$link,
self::QUERY_STORE
);
}
} else {
$this->query(
"SET NAMES '$default_charset' COLLATE '$default_collation';",
$link,
self::QUERY_STORE
);
}

@nijel nijel added the question Used when we need feedback from the submitter or when the issue is a question about PMA label Oct 2, 2017
@mlapkin
Copy link
Author

mlapkin commented Oct 3, 2017

Code above is about configuring collation_connection variable while I'm talking about character_set_server one which I believe developers wanted to display in 'Server charset' line.
Currently even if I have a server configured with character_set_server set to latin1, that line will still display 'UTF-8' although it's not true.

@nijel
Copy link
Contributor

nijel commented Oct 3, 2017

The referenced code does set both collation and character set. So no matter what character set was used on the server, the connection will use utf-8.

@nijel nijel self-assigned this Oct 3, 2017
@nijel nijel closed this as completed Oct 3, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Used when we need feedback from the submitter or when the issue is a question about PMA
Projects
None yet
Development

No branches or pull requests

2 participants