Skip to content

Commit

Permalink
better errors on archive/backup
Browse files Browse the repository at this point in the history
  • Loading branch information
Syxton committed Jul 2, 2024
1 parent fd2ffe8 commit 90d6882
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions classes/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion lang/en/tool_coursearchiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 90d6882

Please sign in to comment.