From 0b2d3353385df9f543b8e47826212c2090d11d85 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Tue, 15 Nov 2022 12:19:24 +0000
Subject: [PATCH] failsafe studyarea assignment detection, fixes #1550

Closes #1550

Merge request studip/studip!969
---
 lib/classes/coursewizardsteps/LVGroupsWizardStep.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/classes/coursewizardsteps/LVGroupsWizardStep.php b/lib/classes/coursewizardsteps/LVGroupsWizardStep.php
index abe00b6baa6..380f33db254 100644
--- a/lib/classes/coursewizardsteps/LVGroupsWizardStep.php
+++ b/lib/classes/coursewizardsteps/LVGroupsWizardStep.php
@@ -407,7 +407,11 @@ class LVGroupsWizardStep implements CourseWizardStep
             }
         } else {
             // optional step if study areas step is activated and at least one area is assigned
-            if (!count($values[__CLASS__]['lvgruppe_selection']['areas'])) {
+            if (
+                !isset($values[__CLASS__]['lvgruppe_selection']['areas'])
+                || !is_array($values[__CLASS__]['lvgruppe_selection']['areas'])
+                || count($values[__CLASS__]['lvgruppe_selection']['areas']) === 0
+            ) {
                 $ok = false;
                 $errors[] = _('Der Veranstaltung muss mindestens eine Lehrveranstaltungsgruppe zugeordnet sein.');
             }
-- 
GitLab