From 91844dae88e7d48d735b3e87f913d279e54e8cb3 Mon Sep 17 00:00:00 2001 From: Markus Date: Fri, 20 Sep 2024 18:59:49 +0200 Subject: [PATCH] include upgrade_plugin_savepoint in upgrade logic --- db/upgrade.php | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/db/upgrade.php b/db/upgrade.php index e9f6edc..7a04fa4 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -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.