Moodle

Bug in backup_generate_preferences_artificially()

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 1.9.3
  • Fix Version/s: None
  • Component/s: Blocks
  • Labels:
    None
  • Difficulty:
    Easy
  • Affected Branches:
    MOODLE_19_STABLE

Description

There is a bug in backup_generate_preferences_artificially() [backup/lib.php].

Essentially, when it is run to generate preferences for an empty course, it generates the following error:

Notice: Undefined property: stdClass::$mods in /Users/ebollens/Sites/ccle/repos/branches/ebollens/batch_backup/moodle/backup/backuplib.php on line 2345

Warning: Invalid argument supplied for foreach() in /Users/ebollens/Sites/ccle/repos/branches/ebollens/batch_backup/moodle/backup/backuplib.php on line 2345

Notice: Undefined property: stdClass::$mods in /Users/ebollens/Sites/ccle/repos/branches/ebollens/batch_backup/moodle/backup/backuplib.php on line 3192

Warning: Invalid argument supplied for foreach() in /Users/ebollens/Sites/ccle/repos/branches/ebollens/batch_backup/moodle/backup/backuplib.php on line 3192

This is because $preferences->mods in backup_generate_preferences_artificially() is set only once modules begin loading, but there is no isset() check in backup execute functions.

The fix is a simple change to backup_generate_preferences_artificially() [backup/lib.php]:

$preferences->backup_name = backup_get_zipfile_name($course, $preferences->backup_unique_code);
$count = 0;

+ $preferences->mods = array();
if ($allmods = get_records("modules") ) {
foreach ($allmods as $mod) {
$modname = $mod->name;

Activity

Hide
Michael de Raadt added a comment -

Thanks for reporting this issue.

We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

Michael d;

lqjjLKA0p6

Show
Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
Hide
Michael de Raadt added a comment -

I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Show
Michael de Raadt added a comment - I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: