Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree sequences can sometimes skip numbers during resorting #3858

Closed
netadmin101 opened this issue Oct 14, 2020 · 4 comments
Closed

Tree sequences can sometimes skip numbers during resorting #3858

netadmin101 opened this issue Oct 14, 2020 · 4 comments
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@netadmin101
Copy link

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;
            }
@netadmin101 netadmin101 added bug Undesired behaviour unverified Some days we don't have a clue labels Oct 14, 2020
@TheWitness
Copy link
Member

Good catch. This is a bug.

TheWitness added a commit that referenced this issue Oct 17, 2020
Tree sequence wrongly increments
@TheWitness TheWitness removed the unverified Some days we don't have a clue label Oct 17, 2020
@TheWitness TheWitness added this to the 1.2.15 milestone Oct 17, 2020
@TheWitness
Copy link
Member

You will have to resort your trees before the changes will take affect for this fix.

@TheWitness TheWitness added the resolved A fixed issue label Oct 17, 2020
@netadmin101
Copy link
Author

Thanks! I resorted and the sequences are working now as I'd expect them to.

@TheWitness
Copy link
Member

@netadmin101, thanks for your help!

@netniV netniV changed the title Tree sequence wrongly increments Tree sequences can sometimes skip numbers during resorting Nov 2, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

2 participants