MDL-57607 upgrade: Add post-upgrade adhoc task for refreshing mod events
authorJun Pataleta <jun@moodle.com>
Tue, 14 Mar 2017 04:56:17 +0000 (12:56 +0800)
committerDan Poltawski <dan@moodle.com>
Tue, 4 Apr 2017 10:01:54 +0000 (11:01 +0100)
Insert an ad-hoc task into the task_adhoc table that updates existing calendar
events to convert them to action-type events, where applicable.

Part of MDL-55611 epic.

lib/db/upgrade.php
version.php

index 5f50fa4..f15afd2 100644 (file)
@@ -2667,5 +2667,20 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint(true, 2017040300.06);
     }
 
+    if ($oldversion < 2017040300.12) {
+        // Create adhoc task for upgrading of existing calendar events.
+        $record = new \stdClass();
+        $record->classname = "\\core\\task\\refresh_mod_calendar_events_task";
+        $record->component = 'core';
+
+        // Next run time based from nextruntime computation in \core\task\manager::queue_adhoc_task().
+        $nextruntime = time() - 1;
+        $record->nextruntime = $nextruntime;
+        $DB->insert_record('task_adhoc', $record);
+
+        // Main savepoint reached.
+        upgrade_main_savepoint(true, 2017040300.12);
+    }
+
     return true;
 }
index d37171e..cae0c2a 100644 (file)
@@ -29,7 +29,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$version  = 2017040300.11;              // YYYYMMDD      = weekly release date of this DEV branch.
+$version  = 2017040300.12;              // YYYYMMDD      = weekly release date of this DEV branch.
                                         //         RR    = release increments - 00 in DEV branches.
                                         //           .XX = incremental changes.