diff options
author | Vladimirs Maksimovs <vladimirs.maksimovs@zabbix.com> | 2022-05-24 12:40:06 +0300 |
---|---|---|
committer | Vladimirs Maksimovs <vladimirs.maksimovs@zabbix.com> | 2022-05-24 12:40:06 +0300 |
commit | 155c3e7ed55221e0cb4f5b136da35585210148b3 (patch) | |
tree | 046fcdccdcc17ef6976b27e0958878ab7f77bcf4 | |
parent | b759e973807329de12051dc5dc96cf0985eebe56 (diff) |
A......... [ZBX-20613] simplified code of circular linkage checks; added a condition to ignore the deleted dependencies upon the circular trigger dependencies check
-rw-r--r-- | ui/include/classes/api/services/CHostBase.php | 10 | ||||
-rw-r--r-- | ui/include/classes/api/services/CTriggerGeneral.php | 15 |
2 files changed, 11 insertions, 14 deletions
diff --git a/ui/include/classes/api/services/CHostBase.php b/ui/include/classes/api/services/CHostBase.php index ecfe47bb6a4..14c0f2bf742 100644 --- a/ui/include/classes/api/services/CHostBase.php +++ b/ui/include/classes/api/services/CHostBase.php @@ -488,19 +488,15 @@ abstract class CHostBase extends CApiService { if (bccomp($template['hostid'], $templateid) == 0) { $template_name = $description; - - if (array_key_exists($template['hostid'], $links_path)) { - $links_path = []; - break; - } } else { $links_path[$template['hostid']] = $description; } } - $circular_linkage = $template_name.($links_path ? ' -> '.implode(' -> ', $links_path) : ''). - ' -> '.$template_name; + $circular_linkage = (bccomp($templateid, $hostid) == 0) + ? $template_name.' -> '.$template_name + : $template_name.' -> '.implode(' -> ', $links_path).' -> '.$template_name; self::exception(ZBX_API_ERROR_PARAMETERS, _s( 'Cannot link template "%1$s" to template "%2$s", because a circular linkage (%3$s) would occur.', diff --git a/ui/include/classes/api/services/CTriggerGeneral.php b/ui/include/classes/api/services/CTriggerGeneral.php index 58901580f07..0b56665cfe5 100644 --- a/ui/include/classes/api/services/CTriggerGeneral.php +++ b/ui/include/classes/api/services/CTriggerGeneral.php @@ -2284,6 +2284,11 @@ abstract class CTriggerGeneral extends CApiService { $_triggerids_down = []; while ($row = DBfetch($result)) { + if (array_key_exists($row['triggerid_up'], $del_dependencies) + && array_key_exists($row['triggerid_down'], $del_dependencies[$row['triggerid_up']])) { + continue; + } + if (!array_key_exists($row['triggerid_up'], $links)) { $_triggerids_down[$row['triggerid_up']] = true; } @@ -2320,19 +2325,15 @@ abstract class CTriggerGeneral extends CApiService { if (bccomp($_triggerid, $triggerid_up) == 0) { $trigger_up_name = $description; - - if (array_key_exists($_triggerid, $links_path)) { - $links_path = []; - break; - } } else { $links_path[$_triggerid] = $description; } } - $circular_linkage = $trigger_up_name.($links_path ? ' -> '.implode(' -> ', $links_path) : ''). - ' -> '.$trigger_up_name; + $circular_linkage = (bccomp($triggerid_up, $triggerid) == 0) + ? $trigger_up_name.' -> '.$trigger_up_name + : $trigger_up_name.' -> '.implode(' -> ', $links_path).' -> '.$trigger_up_name; $non_prototype = $triggers[$triggerid]['flags'] == ZBX_FLAG_DISCOVERY_NORMAL; |