-
-
Notifications
You must be signed in to change notification settings - Fork 427
Description
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:
-
Go to the trees section under management.
-
Create enough trees so that you have more than one. Issue is best seen with 3 or more trees.
-
Take note of values in the mysql database, graph_tree field, specifically the sequence fields
-
Click on a tree name, not the last one in the list.
-
Click the "Edit Tree" button.
-
Click the "Save" button.
-
Observe new values in the mysql database. The tree you just edited has a new sequence that is one higher than the previous max
-
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

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

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

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;
}