Merge branch 'ent-9290-pete-sql-al-buscar-eventos-por-custom-data' into 'develop'

fix error collation events pandora_enterprise#9290

pandora_enterprise#9290

See merge request artica/pandorafms!5030
This commit is contained in:
Jimmy Olano 2022-08-01 00:22:53 +00:00
commit 2a5d075d03
1 changed files with 29 additions and 11 deletions

View File

@ -1091,6 +1091,9 @@ function events_get_all(
// Custom data.
if (empty($filter['custom_data']) === false) {
if (isset($config['dbconnection']->server_version) === true
&& $config['dbconnection']->server_version > 80000
) {
if ($filter['custom_data_filter_type'] === '1') {
$sql_filters[] = sprintf(
' AND JSON_VALID(custom_data) = 1
@ -1104,6 +1107,21 @@ function events_get_all(
io_safe_output($filter['custom_data'])
);
}
} else {
if ($filter['custom_data_filter_type'] === '1') {
$sql_filters[] = sprintf(
' AND JSON_VALID(custom_data) = 1 AND JSON_EXTRACT(custom_data, "$.*") LIKE lower("%%%s%%") ',
$filter['custom_data'],
$filter['custom_data']
);
} else {
$sql_filters[] = sprintf(
' AND JSON_VALID(custom_data) = 1 AND JSON_KEYS(custom_data) REGEXP "%s" ',
$filter['custom_data'],
$filter['custom_data']
);
}
}
}
// Validated or in process by.