diff options
| author | Thomas Hackl <hackl@data-quest.de> | 2024-03-04 08:11:57 +0000 |
|---|---|---|
| committer | Thomas Hackl <hackl@data-quest.de> | 2024-03-04 08:11:57 +0000 |
| commit | e7b6072a4d8ab3a4da0a06e6f161b631fb110680 (patch) | |
| tree | 13cd5d0a3f7e3820d73ba061e474ce11cff0b471 | |
| parent | 3017370070457589a22b0b7be5efe31508f2f718 (diff) | |
Resolve "Call to a member function canVisit() on null"
Closes #3772
Merge request studip/studip!2645
| -rw-r--r-- | app/controllers/course/courseware.php | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/controllers/course/courseware.php b/app/controllers/course/courseware.php index 76f5105..30ab5f1 100644 --- a/app/controllers/course/courseware.php +++ b/app/controllers/course/courseware.php @@ -67,7 +67,7 @@ class Course_CoursewareController extends CoursewareController $lastStructuralElement = \Courseware\StructuralElement::findOneById($last); if ($unit_id === null) { - if ($lastStructuralElement->canVisit(User::findCurrent())) { + if (isset($lastStructuralElement) && $lastStructuralElement->canVisit(User::findCurrent())) { $this->redirectToFirstUnit('course', Context::getId(), $last); } else { $this->redirectToFirstUnit('course', Context::getId(), []); @@ -79,7 +79,7 @@ class Course_CoursewareController extends CoursewareController $this->unit_id = null; $unit = Unit::find($unit_id); if (isset($unit)) { - if ($lastStructuralElement->canVisit($user)) { + if (isset($lastStructuralElement) && $lastStructuralElement->canVisit($user)) { $this->setEntryElement('course', $unit, $last, Context::getId()); } else { $rootElement = [Context::getId() => $unit->structural_element->id]; |
