Skip to content

Tree sequences can sometimes skip numbers during resorting #3858

@netadmin101

Description

@netadmin101

Describe the bug

When saving changes to a tree, the tree sequence in the list of trees is always moved to the bottom of the list. This happens when clicking the "Edit Tree" button and then the "Save" button, and it happens regardless of whether edits are actually made or not. The tree sequence is always set to one above the current maximum. The sequence is then incremented on any subsequent clicks of the save button.

To Reproduce

Steps to reproduce the behavior:

  1. Go to the trees section under management.

  2. Create enough trees so that you have more than one. Issue is best seen with 3 or more trees.

  3. Take note of values in the mysql database, graph_tree field, specifically the sequence fields

  4. Click on a tree name, not the last one in the list.

  5. Click the "Edit Tree" button.

  6. Click the "Save" button.

  7. Observe new values in the mysql database. The tree you just edited has a new sequence that is one higher than the previous max

  8. Click save again. The sequence increments again.

Expected behavior

I would expect the sequence to remain the same as it was before the edits are made. I.E, a tree at the top of the list shouldn't move to the bottom just because an edit was made.

Screenshots

Original contents of mysql table
image

Here I clicked save on the Default tree and the sequence was changed from 1 to 4.
image

One more screenshot: I clicked save a second time, the sequence then changed to 5.
image

Desktop (please complete the following information)

  • OS: Windows 10
  • Browser Chrome/Firefox/IE

Additional context

  • Cacti Version 1.2.14
  • Issue is present on a fresh install
  • We recently updated from 1.2.1 to 1.2.14 and I don't recall it happening in 1.2.1.

In trees.php on line 507, the following if statement appears to always be true. I wish I could provide a suggested fix, but for the life of me I can't find where $save['sequence'] is set. (Or where it should be set if it's not being defined already)

            if (empty($save['sequence'])) {
                    $save['sequence'] = tree_get_max_sequence() + 1;
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behaviourresolvedA fixed issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions