ZABBIX BUGS AND ISSUES
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-7976

Unlinking linked templates from parent template leaves items attached to parent template

    Details

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

        Activity

        Hide
        Ivo Kurzemnieks added a comment - - edited

        (1) No translatable strings changed.

        Oleg Egorov CLOSED

        Show
        Ivo Kurzemnieks added a comment - - edited (1) No translatable strings changed. Oleg Egorov CLOSED
        Hide
        Ivo Kurzemnieks added a comment -

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

        Show
        Ivo Kurzemnieks added a comment - RESOLVED in svn://svn.zabbix.com/branches/dev/ZBX-7976
        Hide
        Oleg Egorov added a comment -

        TESTED, but please add

        $unlinkTemplates = array();
        

        as was discussed

        Show
        Oleg Egorov added a comment - TESTED, but please add $unlinkTemplates = array(); as was discussed
        Hide
        Ivo Kurzemnieks added a comment -

        Template "unlink and clear" has been fixed.

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

        Show
        Ivo Kurzemnieks added a comment - Template "unlink and clear" has been fixed. Fixed in pre-2.2.4rc1 r44128 and pre-2.3.0 (trunk) r44130
        Hide
        Alexander Vladishev added a comment - - edited

        (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.

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

        Alexander Vladishev CLOSED

        Show
        Alexander Vladishev added a comment - - edited (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. Ivo Kurzemnieks RESOLVED in svn://svn.zabbix.com/branches/dev/ZBX-7976 r46020 Alexander Vladishev CLOSED
        Hide
        Ivo Kurzemnieks added a comment -

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

        Show
        Ivo Kurzemnieks added a comment - Fixed in pre-2.2.4.rc1 r46045 and pre-2.3.1 (trunk) r46046

          People

          • Assignee:
            Ivo Kurzemnieks
            Reporter:
            Evgeny
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: