From 90d68825bc859cd431d94f443b27c52c95136752 Mon Sep 17 00:00:00 2001 From: Matt Davidson Date: Tue, 2 Jul 2024 09:06:47 -0400 Subject: [PATCH] better errors on archive/backup --- classes/processor.php | 9 +++++---- lang/en/tool_coursearchiver.php | 3 ++- version.php | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/classes/processor.php b/classes/processor.php index 97f57a5..c8ea3cc 100644 --- a/classes/processor.php +++ b/classes/processor.php @@ -315,11 +315,13 @@ public function execute($outputtype = tool_coursearchiver_tracker::NO_OUTPUT, $t // Loop over the course array. $tracker->jobsize = count($courses); foreach ($courses as $currentcourse) { - if ($this->archivecourse($currentcourse, $delete)) { + $archivestatus = $this->archivecourse($currentcourse, $delete); + if ($archivestatus === true) { $tracker->error = false; $this->total++; } else { $tracker->error = true; + $currentcourse["course"]->error = $archivestatus; $this->errors[] = get_string('errorarchivingcourse', 'tool_coursearchiver', $currentcourse["course"]); } $tracker->jobsdone++; @@ -622,7 +624,7 @@ protected function archivecourse($obj, $delete = true) { require_once($CFG->dirroot . '/backup/controller/backup_controller.class.php'); if (empty($CFG->siteadmins)) { // Should not happen on an ordinary site. - return false; + throw new Exception(get_string('errornoadmins', 'tool_coursearchiver')); } $admin = get_admin(); @@ -710,9 +712,8 @@ protected function archivecourse($obj, $delete = true) { } else { throw new Exception(get_string('errorarchivefile', 'tool_coursearchiver')); } - } catch (Exception $e) { - return false; + return $e->getMessage(); } return true; } diff --git a/lang/en/tool_coursearchiver.php b/lang/en/tool_coursearchiver.php index 0d841d0..aea9b40 100644 --- a/lang/en/tool_coursearchiver.php +++ b/lang/en/tool_coursearchiver.php @@ -95,9 +95,10 @@ $string['endafter'] = "Ends after"; $string['endbefore'] = "Ends before"; $string['error_nocourseid'] = 'Course record did not contain an ID'; +$string['error_noadmins'] = 'There are no admins on this site.'; $string['errorarchivefile'] = 'Course archive file does not exist.'; $string['errorarchivepath'] = 'Archive path could not be created.'; -$string['errorarchivingcourse'] = 'Course: ({$a->id}) {$a->fullname} could not be backed up or archived.'; +$string['errorarchivingcourse'] = 'Course: ({$a->id}) {$a->fullname} could not be backed up or archived. Error: {$a->error}'; $string['errorbackup'] = 'Backup Failed.'; $string['errordeletingcourse'] = 'Course: ({$a->id}) {$a->fullname} could not be deleted.'; $string['erroremptysearch'] = 'No search criteria given.'; diff --git a/version.php b/version.php index 90b2bd4..ed8b5e3 100644 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); $plugin = new stdClass(); -$plugin->version = 2023122100; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2023122100.01; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2014111000; // Requires this Moodle version. $plugin->component = 'tool_coursearchiver'; // Full name of the plugin (used for diagnostics). $plugin->release = '4.1.9 (Build: 2016090200)'; -$plugin->maturity = MATURITY_STABLE; +$plugin->maturity = MATURITY_ALPHA;