-
Incident report
-
Resolution: Fixed
-
Major
-
2.2.1, 2.2.2
When I tried to unlink more than one linked template from parent template with 'Unlink and clear' button, items from these templates were still attached to given template. I've checked the code and seems that 'zbx_array_merge' is the problem.
Here is the code:
templates.php: $_REQUEST['clear_templates'] = zbx_array_merge($_REQUEST['clear_templates'], $unlinkTemplates);
I've chenged it to:
$_REQUEST['clear_templates'] = zbx_flat_array_merge($_REQUEST['clear_templates'], $unlinkTemplates);
and modified 'include/func.inc.php':
--- func.inc.php.old 2014-03-20 16:09:14.000000000 +0400 +++ func.inc.php 2014-03-20 16:08:21.637935103 +0400 @@ -1338,6 +1338,21 @@ return $result; } +function zbx_flat_array_merge() { + $args = func_get_args(); + $result = array(); + foreach ($args as &$array) { + if (!is_array($array)) { + return false; + } + foreach ($array as $key => $value) { + array_push($result, $value); + } + } + + return $result; +} + function uint_in_array($needle, $haystack) { foreach ($haystack as $value) { if (bccomp($needle, $value) == 0) {