MDL-63234 blocks_recent_activity; Ensure courselib is loaded
authorAndrew Nicols <andrew@nicols.co.uk>
Sat, 25 Aug 2018 00:39:03 +0000 (08:39 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Sat, 25 Aug 2018 00:39:03 +0000 (08:39 +0800)
blocks/recent_activity/classes/task/cleanup.php

index c3f34c7..13dc420 100644 (file)
@@ -50,9 +50,12 @@ class cleanup extends \core\task\scheduled_task {
      * Remove old entries from table block_recent_activity
      */
     public function execute() {
      * Remove old entries from table block_recent_activity
      */
     public function execute() {
-        global $DB;
+        global $CFG, $DB;
+        require_once("{$CFG->dirroot}/course/lib.php");
+
         // Those entries will never be displayed as RECENT anyway.
         // Those entries will never be displayed as RECENT anyway.
-        $DB->delete_records_select('block_recent_activity', 'timecreated < ?',
-            array(time() - COURSE_MAX_RECENT_PERIOD));
+        $DB->delete_records_select('block_recent_activity', 'timecreated < ?', [
+                time() - COURSE_MAX_RECENT_PERIOD,
+            ]);
     }
 }
     }
 }