Commit d0a51304 authored by Cédric Anne's avatar Cédric Anne Committed by Johan Cwiklinski
Browse files

Fix charset used in search

parent c11ece2b
......@@ -4557,7 +4557,8 @@ JAVASCRIPT;
$date_computation = $tocompute;
}
if (in_array($searchtype, ["contains", "notcontains"])) {
$date_computation = "CONVERT($date_computation USING utf8)";
$default_charset = DBConnection::getDefaultCharset();
$date_computation = "CONVERT($date_computation USING {$default_charset})";
}
$search_unit = ' MONTH ';
if (isset($searchopt[$ID]['searchunit'])) {
......
......@@ -410,6 +410,8 @@ class Search extends DbTestCase {
->array['sql']
->hasKey('search');
$default_charset = DBConnection::getDefaultCharset();
$this->string($data['sql']['search'])
->contains("`glpi_computers`.`is_deleted` = 0")
->contains("AND `glpi_computers`.`is_template` = 0")
......@@ -424,7 +426,7 @@ class Search extends DbTestCase {
->matches("/OR\s*\(`glpi_computertypes`\.`name`\s*LIKE '%test%'\s*\)/")
->matches("/OR\s*\(`glpi_computermodels`\.`name`\s*LIKE '%test%'\s*\)/")
->matches("/OR\s*\(`glpi_locations`\.`completename`\s*LIKE '%test%'\s*\)/")
->matches("/OR\s*\(CONVERT\(`glpi_computers`\.`date_mod` USING utf8\)\s*LIKE '%test%'\s*\)\)/");
->matches("/OR\s*\(CONVERT\(`glpi_computers`\.`date_mod` USING {$default_charset}\)\s*LIKE '%test%'\s*\)\)/");
}
public function testSearchOnRelationTable() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment