[ZBX-7976] Unlinking linked templates from parent template leaves items attached to parent template Created: 2014 Mar 20  Updated: 2017 May 30  Resolved: 2014 May 30

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 2.2.1, 2.2.2
Fix Version/s: 2.2.4rc1, 2.3.1

Type: Incident report Priority: Major
Reporter: Evgeny Assignee: Ivo Kurzemnieks
Resolution: Fixed Votes: 0
Labels: nested, templatelinking
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

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) {


 Comments   
Comment by Ivo Kurzemnieks [ 2014 Mar 31 ]

(1) No translatable strings changed.

oleg.egorov CLOSED

Comment by Ivo Kurzemnieks [ 2014 Mar 31 ]

RESOLVED in svn://svn.zabbix.com/branches/dev/ZBX-7976

Comment by Oleg Egorov (Inactive) [ 2014 Apr 01 ]

TESTED, but please add

$unlinkTemplates = array();

as was discussed

Comment by Ivo Kurzemnieks [ 2014 Apr 07 ]

Template "unlink and clear" has been fixed.

Fixed in pre-2.2.4rc1 r44128 and pre-2.3.0 (trunk) r44130

Comment by Alexander Vladishev [ 2014 May 30 ]

(2) REOPENED. Cannot "unlink and clear" a template from an another template. There is an error:

Field "clear_templates" is not integer.

"unlink and clear" a template from a host is work fine.

iivs RESOLVED in svn://svn.zabbix.com/branches/dev/ZBX-7976 r46020

sasha CLOSED

Comment by Ivo Kurzemnieks [ 2014 May 30 ]

Fixed in pre-2.2.4.rc1 r46045 and pre-2.3.1 (trunk) r46046

Generated at Sat Apr 27 07:12:36 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.