From daf05d559a60a01e80b159cbff3189ab11f5f7c5 Mon Sep 17 00:00:00 2001 From: Melanie Treitinger Date: Wed, 6 Dec 2023 11:32:39 +0100 Subject: [PATCH] fix error when otherindex does not exist --- classes/local/manager/workflow_manager.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/classes/local/manager/workflow_manager.php b/classes/local/manager/workflow_manager.php index 13d5cae6..e77a837b 100644 --- a/classes/local/manager/workflow_manager.php +++ b/classes/local/manager/workflow_manager.php @@ -328,12 +328,14 @@ public static function change_sortindex($workflowid, $up) { array( 'sortindex' => $otherindex) ); - $otherworkflow = workflow::from_record($otherrecord); + if (false !== $otherrecord) { + $otherworkflow = workflow::from_record($otherrecord); + $otherworkflow->sortindex = $index; + self::insert_or_update($otherworkflow); + } $workflow->sortindex = $otherindex; - $otherworkflow->sortindex = $index; self::insert_or_update($workflow); - self::insert_or_update($otherworkflow); $transaction->allow_commit(); }