MDL-66970 analytics: Fix incorrect use of ??
authorDavid Monllaó <davidm@moodle.com>
Thu, 17 Oct 2019 09:08:51 +0000 (17:08 +0800)
committerDavid Monllaó <davidm@moodle.com>
Mon, 21 Oct 2019 21:13:26 +0000 (05:13 +0800)
course/classes/analytics/target/course_enrolments.php

index 233fa09..835fe66 100644 (file)
@@ -302,8 +302,20 @@ abstract class course_enrolments extends \core_analytics\local\target\binary {
     protected function enrolment_active_during_analysis_time(int $sampleid, int $starttime, int $endtime) {
 
         $userenrol = $this->retrieve('user_enrolments', $sampleid);
-        $enrolstart = $userenrol->timestart ?? $userenrol->timecreated;
-        $enrolend = $userenrol->timeend ?? PHP_INT_MAX;
+
+        if (!empty($userenrol->timestart)) {
+            $enrolstart = $userenrol->timestart;
+        } else {
+            // This is always set.
+            $enrolstart = $userenrol->timecreated;
+        }
+
+        if (!empty($userenrol->timeend)) {
+            $enrolend = $userenrol->timeend;
+        } else {
+            // Default to tre end of the world.
+            $enrolend = PHP_INT_MAX;
+        }
 
         if ($endtime && $endtime < $enrolstart) {
             /* The enrolment starts/ed after the analysis end time.