From 28660ad79041b7a7d0706c85362e20b6ad530f6e Mon Sep 17 00:00:00 2001 From: Riedler Date: Sat, 4 Oct 2025 20:26:02 +0200 Subject: [PATCH] fix: add some debug statements in case of exceptions those should make it easier to identify issue EDUPL-19 --- lbplanner/classes/helpers/kanban_helper.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lbplanner/classes/helpers/kanban_helper.php b/lbplanner/classes/helpers/kanban_helper.php index 3999067c..f106f571 100644 --- a/lbplanner/classes/helpers/kanban_helper.php +++ b/lbplanner/classes/helpers/kanban_helper.php @@ -72,11 +72,25 @@ public static function get_entry(int $userid, int $cmid): ?kanbanentry { public static function set_entry(kanbanentry $entry): void { global $DB, $CFG; - $DB->delete_records(self::TABLE, ['userid' => $entry->userid, 'cmid' => $entry->cmid]); + try { + $DB->delete_records(self::TABLE, ['userid' => $entry->userid, 'cmid' => $entry->cmid]); + } catch (\dml_exception $e) { + // Needed for low-reporting contexts such as a prod server. + echo 'error while trying to delete preexisting kanban entries: '.$e->getMessage()."\nFurther info:\n".$e->debuginfo; + var_dump($entry); + throw $e; + } if ($entry->column !== KANBANCOL_TYPE_NUMERIC::BACKLOG) { $table = $CFG->prefix . self::TABLE; - // Moodle is too stupid to compensate for 'column' being a keyword so I need to shit my own ass manually. - $newid = $DB->execute("INSERT INTO {$table} VALUES (null,?,?,?)", [$entry->userid, $entry->cmid, $entry->column]); + try { + // Moodle is too stupid to compensate for 'column' being a keyword so I need to shit my own ass manually. + $newid = $DB->execute("INSERT INTO {$table} VALUES (null,?,?,?)", [$entry->userid, $entry->cmid, $entry->column]); + } catch (\dml_exception $e) { + // Needed for low-reporting contexts such as a prod server. + echo 'error while trying to insert new kanban entry: '.$e->getMessage()."\nFurther info:\n".$e->debuginfo; + var_dump($entry); + throw $e; + } $entry->set_fresh($newid); } }