Problem with automated course backup

Problem with automated course backup

by Jez H -
Number of replies: 0
Hello All,

I have the following error in cron.php

Invalid argument supplied for foreach() in /WWW/moodle/backup/backuplib.php on line 2218

The line in question is:

foreach ($instances as $id => $instance) {

which is found in the following function:

 /* Finds all related roles used in course, mod and blocks context
 * @param object $preferences
 * @param object $course
 * @return array of role objects
 */

function backup_fetch_roles($preferences) {

 global $CFG;
 $contexts = array();
 $roles = array();

 /// adding course context
 $coursecontext = get_context_instance(CONTEXT_COURSE, $preferences->backup_course);
 $contexts[$coursecontext->id] = $coursecontext;

 /// adding mod contexts
 $mods = $preferences->mods;
 foreach ($mods as $modname => $mod) {
 $instances = $mod->instances;
 foreach ($instances as $id => $instance) {
 // if this type of mod is to be backed up
 if ($instance->backup) {
 $cm = get_coursemodule_from_instance($modname, $id);
 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 // put context in array keys
 $contexts[$context->id] = $context;
 }
 }
}

I am assuming this error is caused by incorrect user records (I know our database has a lot of discrepancies in this area).

What I need to know is whether this error could stop a course being backed up?

The list of courses actually sent to file is less than the total that exists in Moodle, I am wondering if this is likely?

My assumption is that, as this is only a "warning" and not an error, that the backup should proceed.

If anyone has any info on this I would be grateful!

Jeremy


Average of ratings: -