From c4971efd6c978767bfd32b38a98743e1d001a8bc Mon Sep 17 00:00:00 2001 From: Alexander Van der Bellen Date: Mon, 18 Nov 2024 16:22:30 +0800 Subject: [PATCH] Fix Adhoc task failed: mod_cms\task\update_files_context,Class 'csv_export_writer' not found --- classes/task/update_files_context.php | 4 +++- db/upgrade.php | 4 ++-- version.php | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/classes/task/update_files_context.php b/classes/task/update_files_context.php index ede158f..e2d675f 100644 --- a/classes/task/update_files_context.php +++ b/classes/task/update_files_context.php @@ -61,7 +61,9 @@ public function execute(): void { * @return csv_export_writer The CSV export writer containing the results of the task. */ private static function update_contexts(?int $courseid, bool $dryrun): csv_export_writer { - global $DB; + global $CFG, $DB; + + require_once($CFG->libdir . '/csvlib.class.php'); $sql = "SELECT f.*, ctx.id AS ctxid, cms.course AS courseid FROM {files} f diff --git a/db/upgrade.php b/db/upgrade.php index 8c243e0..d691e2b 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -413,12 +413,12 @@ function xmldb_cms_upgrade($oldversion) { upgrade_mod_savepoint(true, 2024090303, 'cms'); } - if ($oldversion < 2024090304) { + if ($oldversion < 2024090305) { // Run ad hoc task for updating contextid in the files table. $task = \mod_cms\task\update_files_context::instance(null, false); manager::queue_adhoc_task($task); - upgrade_mod_savepoint(true, 2024090304, 'cms'); + upgrade_mod_savepoint(true, 2024090305, 'cms'); } return true; diff --git a/version.php b/version.php index 6ee8741..9f811c3 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024090303; +$plugin->version = 2024090305; $plugin->requires = 2022112800; // Moodle 4.1 and above. $plugin->supported = [401, 401]; // Moodle 4.1. $plugin->component = 'mod_cms';