From 001f753f77c952986ccf18350bb61682ab5cd695 Mon Sep 17 00:00:00 2001 From: Riedler Date: Thu, 25 Sep 2025 20:12:05 +0200 Subject: [PATCH 1/2] fix: minor fixes in upgrade logic --- lbplanner/db/upgrade.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lbplanner/db/upgrade.php b/lbplanner/db/upgrade.php index 7d871a6c..39606d23 100644 --- a/lbplanner/db/upgrade.php +++ b/lbplanner/db/upgrade.php @@ -83,8 +83,20 @@ function xmldb_local_lbplanner_upgrade($oldversion): bool { $courseids = $DB->get_fieldset(course_helper::EDUPLANNER_COURSE_TABLE, 'courseid'); $courseids = array_unique($courseids, SORT_REGULAR); // Dedupe. foreach ($courseids as $courseid) { + try { + get_course($courseid); + } catch (dml_exception) { + /* This means the course doesn't actually exist - meaning it got deleted and not yet cleaned up in the + * DB. normally I would clean it up here, but this upgrade function has to do as little as possible, so + * we can as ensure it actually works as expected under all circumstances. This part of the code is very + * hard to debug and thus uncomfortably fragile. + */ + continue; + } core_tag_tag::add_item_tag('core', 'course', $courseid, context_course::instance($courseid), $tag->rawname); } + + upgrade_plugin_savepoint(true, 202509060001, 'local', 'lbplanner'); } return true; } From 93e125d99347f96e206a854d5b21009adf113416 Mon Sep 17 00:00:00 2001 From: Riedler Date: Fri, 26 Sep 2025 12:02:03 +0200 Subject: [PATCH 2/2] fix: installer hotfix --- lbplanner/db/install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lbplanner/db/install.php b/lbplanner/db/install.php index 71a98d0b..b0dd2a5a 100644 --- a/lbplanner/db/install.php +++ b/lbplanner/db/install.php @@ -23,12 +23,12 @@ * @license https://creativecommons.org/licenses/by-nc-sa/4.0/ CC-BY-NC-SA 4.0 International or later */ -use local_lbplanner\helpers\config_helper; - +use local_lbplanner\helpers\{config_helper, course_helper}; /** * Runs when plugin is first installed */ function xmldb_local_lbplanner_install() { config_helper::add_customfield(); + core_tag_tag::create_if_missing(core_tag_collection::get_default(), [course_helper::EDUPLANNER_TAG], true); }