From 2a33a6009383bbf115bb780a5ee1354efaa79c0a Mon Sep 17 00:00:00 2001 From: Kata <35190838+olivabigyo@users.noreply.github.com> Date: Thu, 14 Mar 2024 11:39:07 +0100 Subject: [PATCH] Fix step and trigger reordering: only change the relevant workflow (#200) --- classes/local/manager/step_manager.php | 4 ++-- classes/local/manager/trigger_manager.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/local/manager/step_manager.php b/classes/local/manager/step_manager.php index c82c9cec..3158cd40 100644 --- a/classes/local/manager/step_manager.php +++ b/classes/local/manager/step_manager.php @@ -137,8 +137,8 @@ private static function remove_from_sortindex(&$toberemoved) { global $DB; if (isset($toberemoved->sortindex)) { $subplugins = $DB->get_records_select('tool_lifecycle_step', - "sortindex > $toberemoved->sortindex", - ['workflowid' => $toberemoved->workflowid]); + 'workflowid = :workflowid AND sortindex > :sortindex', + ['workflowid' => $toberemoved->workflowid, 'sortindex' => $toberemoved->sortindex]); foreach ($subplugins as $record) { $subplugin = step_subplugin::from_record($record); $subplugin->sortindex--; diff --git a/classes/local/manager/trigger_manager.php b/classes/local/manager/trigger_manager.php index 20f20a21..656d4233 100644 --- a/classes/local/manager/trigger_manager.php +++ b/classes/local/manager/trigger_manager.php @@ -179,8 +179,8 @@ private static function remove_from_sortindex(&$toberemoved) { global $DB; if (isset($toberemoved->sortindex)) { $subplugins = $DB->get_records_select('tool_lifecycle_trigger', - "sortindex > $toberemoved->sortindex", - ['workflowid' => $toberemoved->workflowid]); + 'workflowid = :workflowid AND sortindex > :sortindex', + ['workflowid' => $toberemoved->workflowid, 'sortindex' => $toberemoved->sortindex]); foreach ($subplugins as $record) { $subplugin = trigger_subplugin::from_record($record); $subplugin->sortindex--;