Skip to content
Snippets Groups Projects
Commit e7b6072a authored by Thomas Hackl's avatar Thomas Hackl
Browse files

Resolve "Call to a member function canVisit() on null"

Closes #3772

Merge request studip/studip!2645
parent 30173700
No related branches found
No related tags found
No related merge requests found
......@@ -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];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment