Skip to content
Snippets Groups Projects

#3522178: Added a NULL check in data integrity checker; moved course status cleanup to a cron queue.

Merged #3522178: Added a NULL check in data integrity checker; moved course status cleanup to a cron queue.
2 unresolved threads
Merged Marcin Grabias requested to merge issue/lms-3522178:3522178-orphaned-course-status into 1.0.x
2 unresolved threads
Files
5
@@ -43,9 +43,12 @@ class CourseStatus extends ContentEntityBase implements CourseStatusInterface {
/**
* {@inheritdoc}
*/
public function getCourse(): Course {
public function getCourse(): ?Course {
/** @var \Drupal\Core\Entity\EntityInterface|null */
$course = $this->get('gid')->entity;
\assert($course instanceof Course);
if ($course !== NULL) {
\assert($course instanceof Course);
}
return $course;
}
@@ -222,23 +225,6 @@ class CourseStatus extends ContentEntityBase implements CourseStatusInterface {
return (bool) $this->get('current')->value;
}
/**
* {@inheritdoc}
*/
public static function actOnCourseDeletion(string $gid): void {
// Remove Course Status entities.
$storage = \Drupal::entityTypeManager()->getStorage('lms_course_status');
$affected_status_ids = $storage->getQuery()
->accessCheck(FALSE)
->condition('gid', $gid)
->execute();
if (\count($affected_status_ids) === 0) {
return;
}
$statuses = $storage->loadMultiple($affected_status_ids);
$storage->delete($statuses);
}
/**
* {@inheritdoc}
*/
Loading