MDL-23610 finally fixed the broken utf8 detection in mysqli driver

this was actually causing tons of false reports because people are often creating the database without the encoding parameter, especially when testing upgrades
This commit is contained in:
Petr Skoda
2010-11-17 01:58:38 +00:00
parent e53162b9d2
commit cd4f18595a
+29 -2
View File
@@ -572,11 +572,38 @@ class mysqli_native_moodle_database extends moodle_database {
$result = $this->mysqli->query($sql);
$this->query_end($result);
$return = false;
if ($result) {
while($row = $result->fetch_assoc()) {
if (isset($row['Value'])) {
$return = (strtoupper($row['Value']) === 'UTF8' or strtoupper($row['Value']) === 'UTF-8');
}
break;
}
$result->close();
return true;
}
return false;
if (!$return) {
return false;
}
$sql = "SHOW LOCAL VARIABLES LIKE 'collation_database'";
$this->query_start($sql, null, SQL_QUERY_AUX);
$result = $this->mysqli->query($sql);
$this->query_end($result);
$return = false;
if ($result) {
while($row = $result->fetch_assoc()) {
if (isset($row['Value'])) {
$return = (strpos($row['Value'], 'latin1') !== 0);
}
break;
}
$result->close();
}
return $return;
}
/**