diff --git a/classes/local/manager/workflow_manager.php b/classes/local/manager/workflow_manager.php index 4d395090..16d7d3f5 100644 --- a/classes/local/manager/workflow_manager.php +++ b/classes/local/manager/workflow_manager.php @@ -366,12 +366,14 @@ public static function change_sortindex($workflowid, $up) { [ '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(); }