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

Fix sortindex handling on step deletion #200

Merged
merged 1 commit into from
Mar 14, 2024

Conversation

olivabigyo
Copy link
Contributor

There is a very subtle bug in the remove_from_sortindex function in classes/local/manager/step_manager.php. It looks like it should affect only the steps in the same workflow, but actually the workflowid 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. Create two workflows. First with 3 steps, the Second with at least one step. (Choose whatever steps you want.)
  2. Remove the first step in the Second workflow.
  3. Check the sortindexes for the First workflow's steps in the DB, it's now 1, 1, 2 instead of 1, 2, 3.
  4. You can also notice problems by inspecting the First workflow on the UI. The order of the first two steps might have changed already (depending on how the DB orders the two steps with the same 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.

@NinaHerrmann
Copy link
Contributor

Thank you so much for doing the whole packet (reporting, resolving etc. 😍 )

@NinaHerrmann NinaHerrmann merged commit 2a33a60 into learnweb:master Mar 14, 2024
23 checks passed
NinaHerrmann added a commit that referenced this pull request Jun 19, 2024
* Removed ,

* CI: Update for Moodle 4.2

* Workflow backup: Do not save attributes when they are null

* Bump version

* MBS-7377: Fix workflowoverview for big instances

* Fix wrong calculation of courses counts in template context

* fix upload workflow (#185)

* fix upload workflow

* inserting feedback

* finally

* Add check if process exists. (#191)

This prevents courses to be processed which had been rescued by the teacher.

* Update README.md

Make Subplugin List (and link to wiki) more apparent

* Improve help text for integration of icons (manual trigger) (#193)

* Improved help text for the integration of icons

* Improved help text for the integration of icons

* Update for Moodle 4.3 (#190)

* CI: Update for Moodle 4.3

* Prevent dynamic property access on classes for PHP 8.2

* phpcbf for styles etc.

---------

Co-authored-by: Justus Dieckmann <justusdieckmann@wwu.de>
Co-authored-by: NinaHerrmann <nina.herrmann@uni-muenster.de>

* Hide menu when there is no manual workflow (#195)

Co-authored-by: Justus Dieckmann <justusdieckmann@wwu.de>

* Fix step and trigger reordering: only change the relevant workflow (#200)

* Reorder the remaining active workflows when disabling a workflow (#201)

This fixes #128.

* Show menu entry when a manual or automatic workflow is active (#199)

* Show menu point when a manual or automatic workflow is active

* Rename reset cache function

* Show menu entry if there are workflows other than the default two

---------

Co-authored-by: Justus Dieckmann <justusdieckmann@wwu.de>

* Check backup consistency before importing workflow (#196)

* Check backup consistency before importing workflow

* Fix PHPDocs

* Use existing category in backup_and_restore test

* lifecycletrigger_categories: A bit of general refactoring

* lifecycletrigger_categories: Don't fail if category doesn't exist

* Add possibility to force import of errorneous backup

* Use $force = false as default in restore_workflow:execute

* Display only unique errors when Workflows causes multiple errors

---------

Co-authored-by: Justus Dieckmann <justusdieckmann@wwu.de>
Co-authored-by: NinaHerrmann <nina.herrmann@uni-muenster.de>

* CI: Update for Moodle 4.4

* Codestyle PHPCBF

* Sort strings in lang files alphabetically

* Fix sortindex gaps in upgrade step

* Bump version

* The columns in active_manual_workflows_table shouldn't be sortable

* Shell escape the release notes in the release workflow (#207)

Co-authored-by: Justus Dieckmann <justusdieckmann@wwu.de>

* Fix mustache

* added mtrace statement for logging failed mails (#214)

* Shell escape release workflow for realsies this time (#208)

---------

Co-authored-by: Justus Dieckmann <justusdieckmann@wwu.de>
Co-authored-by: Philipp Memmel <philipp.memmel@gmail.com>
Co-authored-by: Justus Dieckmann <45795270+justusdieckmann@users.noreply.github.com>
Co-authored-by: Melanie Treitinger <66598405+melanietreitinger@users.noreply.github.com>
Co-authored-by: KerstinSc <kerstin.schmidt@th-nuernberg.de>
Co-authored-by: Kata <35190838+olivabigyo@users.noreply.github.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants