Fix sortindex
handling on step deletion
#200
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a very subtle bug in the
remove_from_sortindex
function inclasses/local/manager/step_manager.php
. It looks like it should affect only the steps in the same workflow, but actually theworkflowid
is only passed as a parameter, but not actually used in the SELECT condition. So, what actually happens is that every workflow (that have enough) steps is changed when you delete a step from any workflow. Resulting in reordering of steps and other problems, like being unable to reorder steps anymore.How to reproduce:
1, 1, 2
instead of1, 2, 3
.sortindex
). But, if you try to move the first step down, it will become the third instead of the second. Etc.This was very hard to debug, because you only notice that something happened to your workflows later, and don't associate this with changing things in another workflow.
Exactly the same bug is present in
trigger_manager.php
, though it's less problematic as the order of the triggers is not that important.This PR contains the simple fix for the problem.