Skip to content

Commit

Permalink
QA: Backport MySQL 8.x Regex Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWitness committed Jan 26, 2025
1 parent 6be8c48 commit 0d198c5
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions lib/api_automation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3086,13 +3086,30 @@ function automation_add_tree($host_id, $tree) {
function automation_find_os($sysDescr, $sysObject, $sysName) {
$sql_where = '';

$sql_where .= "WHERE (? REGEXP sysDescr OR ? LIKE CONCAT('%', sysDescr, '%'))";
$sql_where .= " AND (? REGEXP sysOid OR ? LIKE CONCAT('%', sysOid, '%'))";
$sql_where .= " AND (? REGEXP sysName OR ? LIKE CONCAT('%', sysName, '%'))";
if ($sysDescr != '') {
$sql_where .= ($sql_where != '' ? ' AND ':'WHERE ') . "(? REGEXP CONCAT('/', sysDescr, '/') OR ? LIKE CONCAT('%%', sysDescr, '%%'))";

$params[] = $sysDescr;
$params[] = $sysDescr;
}

if ($sysObject != '') {
$sql_where .= ($sql_where != '' ? ' AND ':'WHERE ') . "(? REGEXP CONCAT('/', sysOid, '/') OR ? LIKE CONCAT('%%', sysOid, '%%'))";

$params[] = $sysObject;
$params[] = $sysObject;
}

if ($sysName != '') {
$sql_where .= ($sql_where != '' ? ' AND ':'WHERE ') . "(? REGEXP CONCAT('/', sysName, '/') OR ? LIKE CONCAT('%%', sysName, '%%'))";

$params[] = $sysName;
$params[] = $sysName;
}

$params = array($sysDescr, $sysDescr, $sysObject, $sysObject, $sysName, $sysName);

$result = db_fetch_row_prepared("SELECT at.*,ht.name
$result = db_fetch_row_prepared("SELECT at.*, ht.name
FROM automation_templates AS at
INNER JOIN host_template AS ht
ON ht.id=at.host_template
Expand Down

0 comments on commit 0d198c5

Please sign in to comment.