Skip to content

Commit

Permalink
include upgrade_plugin_savepoint in upgrade logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Glutamat42 committed Sep 20, 2024
1 parent e30a16c commit 91844da
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,35 @@

/**
* @throws moodle_exception
* @throws not_an_adler_course_exception
*/
function xmldb_local_adler_upgrade($oldversion): bool {
// global $CFG, $DB;
// $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.

if ($oldversion < 2024090900) {
$courses = get_courses('all');
foreach ($courses as $course) {
if ($course->id == 1) {
// moodle special course for startpage
continue;
}
try {
$upgrader = new upgrade_3_2_0_to_4_0_0_completionlib($course->id);
$upgrader->execute();
} catch (not_an_adler_course_exception $e) {
// Do nothing
$success = true;
try {
$courses = get_courses('all');
foreach ($courses as $course) {
if ($course->id == 1) {
// moodle special course for startpage
continue;
}
try {
$upgrader = new upgrade_3_2_0_to_4_0_0_completionlib($course->id);
$upgrader->execute();
} catch (not_an_adler_course_exception $e) {
// Do nothing
}
}
} catch (moodle_exception $e) {
// $success = false;
throw $e;
}

// Logging the upgrade.
upgrade_plugin_savepoint($success, 2024090900, 'local', 'adler');

}

// Everything has succeeded to here. Return true.
Expand Down

0 comments on commit 91844da

Please sign in to comment.