Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-82750

Backing up a section with the backup_async_message_users admin setting enabled causes exception

    • MOODLE_405_STABLE
    • MDL-82750-401
    • MDL-82750-403
    • MDL-82750-404
    • MDL-82750-405
    • MDL-82750-500
    • MDL-82750-main
    • Hide

      Disable the backup_async_message_users setting

      Show
      Disable the backup_async_message_users setting
    • Hide
      • Assuming that enableasyncbackup is on as by default (To be found in Administration > Courses > Backups > Asynchronous backup/restore)
      • From Administration > Courses > Backups > Asynchronous backup/restore enable backup | backup_async_message_users (default)
      • With a role that can view a course and do a backup navigate to a course section to find a valid section id and use it to call the url <SITE>/backup/backup.php?id=<COURSEID>&section=<SECTIONID>
      • Make sure that in the table mdl_course there is no item with id <SECTIONID> !!!
      • Start the backup (directly with "Jump to the final step")
      • Run the cron
      • Confirm that without the patch the task fails with an error similar to:

      Execute adhoc task: core\task\asynchronous_backup_task Adhoc task id: 16 Adhoc task custom data: {"backupid":"00a27a57617fd435dc03c88045946f74"} ... started 15:44:36. Current memory use 48.8 MB. Processing asynchronous backup for backup: 00a27a57617fd435dc03c88045946f74 ... used 281 dbqueries ... used 0.39941382408142 seconds Adhoc task failed: core\task\asynchronous_backup_task,Can't find data record in database table course. (SELECT id,category FROM {course} WHERE id = ? [array ( 0 => '6', )]) Debug info: SELECT id,category FROM {course} WHERE id = ? [array ( 0 => '6', )] Backtrace: * line 1638 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select() * line 200 of /lib/classes/context/course.php: call to moodle_database->get_record() * line 147 of /backup/util/helper/async_helper.class.php: call to core\context\course::instance() * line 129 of /backup/util/helper/async_helper.class.php: call to async_helper->get_resource_link() * line ? of unknownfile: call to async_helper->lookup_message_variables() * line 174 of /backup/util/helper/async_helper.class.php: call to preg_replace_callback() * line 76 of /lib/classes/task/asynchronous_backup_task.php: call to async_helper->send_message() * line 519 of /lib/classes/cron.php: call to core\task\asynchronous_backup_task->execute() * line 302 of /lib/classes/cron.php: call to core\cron::run_inner_adhoc_task() * line 128 of /lib/classes/cron.php: call to core\cron::run_adhoc_tasks() * line 186 of /admin/cli/cron.php: call to core\cron::run_main_process() 
      

      (see admin/tasklogs.php with filter asyncronous backup task)

      • Confirm that with the patch the task succeeds and the link "restore page" in the line you can access the backup on the restore page corresponds to <SITE>/backup/restorefile.php?contextid=<CONTEXTID> where <CONTEXTID> is the context id of the course with id <COURSEID>.
      Show
      Assuming that enableasyncbackup is on as by default (To be found in Administration > Courses > Backups > Asynchronous backup/restore ) From Administration > Courses > Backups > Asynchronous backup/restore enable backup | backup_async_message_users (default) With a role that can view a course and do a backup navigate to a course section to find a valid section id and use it to call the url <SITE>/backup/backup.php?id=<COURSEID>&section=<SECTIONID> Make sure that in the table mdl_course there is no item with id <SECTIONID> !!! Start the backup (directly with "Jump to the final step") Run the cron Confirm that without the patch the task fails with an error similar to: Execute adhoc task: core\task\asynchronous_backup_task Adhoc task id: 16 Adhoc task custom data: { "backupid" : "00a27a57617fd435dc03c88045946f74" } ... started 15 : 44 : 36 . Current memory use 48.8 MB. Processing asynchronous backup for backup: 00a27a57617fd435dc03c88045946f74 ... used 281 dbqueries ... used 0.39941382408142 seconds Adhoc task failed: core\task\asynchronous_backup_task,Can 't find data record in database table course. (SELECT id,category FROM {course} WHERE id = ? [array ( 0 => ' 6 ', )]) Debug info: SELECT id,category FROM {course} WHERE id = ? [array ( 0 => ' 6 ', )] Backtrace: * line 1638 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select() * line 200 of /lib/classes/context/course.php: call to moodle_database->get_record() * line 147 of /backup/util/helper/async_helper. class .php: call to core\context\course::instance() * line 129 of /backup/util/helper/async_helper. class .php: call to async_helper->get_resource_link() * line ? of unknownfile: call to async_helper->lookup_message_variables() * line 174 of /backup/util/helper/async_helper. class .php: call to preg_replace_callback() * line 76 of /lib/classes/task/asynchronous_backup_task.php: call to async_helper->send_message() * line 519 of /lib/classes/cron.php: call to core\task\asynchronous_backup_task->execute() * line 302 of /lib/classes/cron.php: call to core\cron::run_inner_adhoc_task() * line 128 of /lib/classes/cron.php: call to core\cron::run_adhoc_tasks() * line 186 of /admin/cli/cron.php: call to core\cron::run_main_process() (see admin/tasklogs.php with filter asyncronous backup task ) Confirm that with the patch the task succeeds and the link "restore page" in the line you can access the backup on the restore page corresponds to <SITE>/backup/restorefile.php?contextid=<CONTEXTID> where <CONTEXTID> is the context id of the course with id <COURSEID> .
    • Hide

      Fails against automated checks.

      Checked MDL-82750 using repository: https://github.com/pmaneggia/moodle.git

      Should these errors be fixed?

      Built on: Thu Jun 12 12:10:32 UTC 2025

      Show
      Fails against automated checks. Checked MDL-82750 using repository: https://github.com/pmaneggia/moodle.git MOODLE_401_STABLE (0 errors / 0 warnings) [branch: MDL-82750-401 | CI Job ] MOODLE_403_STABLE [branch: MDL-82750-403 | CI Job ] Error: The MDL-82750 -403 branch at https://github.com/pmaneggia/moodle.git is very old (>60 days ago). Please rebase against current MOODLE_403_STABLE. MOODLE_404_STABLE (0 errors / 0 warnings) [branch: MDL-82750-404 | CI Job ] MOODLE_405_STABLE (0 errors / 1 warnings) [branch: MDL-82750-405 | CI Job ] overview (0/1) , phplint (0/0) , phpcs (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (0/0) , savepoint (0/0) , thirdparty (0/0) , externalbackup (0/0) , grunt (0/0) , shifter (0/0) , mustache (0/0) , gherkin (0/0) , Warn: The MDL-82750 -405 branch at https://github.com/pmaneggia/moodle.git has not been rebased recently (>20 days ago). MOODLE_500_STABLE (0 errors / 1 warnings) [branch: MDL-82750-500 | CI Job ] overview (0/1) , phplint (0/0) , phpcs (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (0/0) , savepoint (0/0) , thirdparty (0/0) , externalbackup (0/0) , grunt (0/0) , shifter (0/0) , mustache (0/0) , gherkin (0/0) , Warn: The MDL-82750 -500 branch at https://github.com/pmaneggia/moodle.git has not been rebased recently (>20 days ago). main (0 errors / 0 warnings) [branch: MDL-82750-main | CI Job ] Should these errors be fixed? Built on: Thu Jun 12 12:10:32 UTC 2025

      When having enabled the `backup_async_message_users` admin setting, you can't complete section backups. This affects the new version of the block_sharing_cart plugin.

       

      The `\async_helper::get_resource_link()` method doesn't support 
      `\backup::TYPE_1SECTION` and tries to find a course context by a sectionid.
       
      I recommend changing the current ifelse into a switch statement with the 3 cases (activity, course and section) and a default case throwing an unknown backup type exception.

            ManeggiaP Paola Maneggia
            frederikmillingpytlick Frederik Milling Pytlick
            Meirza Meirza
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.