Moodle

import_backup_file_silently() behaves improperly

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 1.7
  • Fix Version/s: None
  • Component/s: Backup
  • Labels:
    None
  • Environment:
    Moodle 1.7, Apache 2.0.59, PHP 5.1.6, MySQL 4.1.21

Description

http://moodle.org/mod/forum/discuss.php?d=62033

restorelib.php, restore_execute(), line 5420:
if ($status = restore_open_html($restore,$course_header)){
echo "<li>Creating the Restorelog.html in the course backup folder</li>";
}

This is fine, but it's within the first clause of an if statement (If we've selected to restore into new course). If you're restoring to an existing course (as in my case, where I've created a large number of courses and I'm now trying to restore one template course to a lot of different places), this is never called, so when at the end of the restore_execute() function in line 5900, it's closed, the closure fails and the function returns false, which triggers the error message in import_backup_file_silently() but there's nothing in $errorstr for the error message to report and all the work has completed successfully anyway. So I moved the above lines to open the restorelog.html file outside the if statement and rewrote the code that closes it at line 5900:

if (!defined('RESTORE_SILENTLY')) {
echo "<li>Closing the Restorelog.html file.<li>";
}
$status = restore_close_html($restore);
if (!$status){
if (!defined('RESTORE_SILENTLY')) {
notify("Could not close the Restorelog.html file");
} else {
$errorstr = "Could not close the Restorelog.html file";
return false;
}
}

Oh, and I altered the opening of the file as well (the above works, it's just that it echo()s stuff to the screen instead of being silent):

if (!defined('RESTORE_SILENTLY')) {
echo "<li>Creating the Restorelog.html in the course backup folder</li>";
}
$status = restore_open_html($restore,$course_header);
if (!$status){
if (!defined('RESTORE_SILENTLY')) {
notify("Could not open the Restorelog.html file");
} else {
$errorstr = "Could not open the Restorelog.html file";
return false;
}
}

Activity

Hide
Eloy Lafuente (stronk7) added a comment -

Assigning this to Penny.

Show
Eloy Lafuente (stronk7) added a comment - Assigning this to Penny.
Hide
Penny Leach added a comment -

I'll be looking at this next week.

Show
Penny Leach added a comment - I'll be looking at this next week.
Hide
Wen Hao Chuang added a comment -

Is this related to MDL-10882 ? Penny do you have any update on this? Many thanks

Show
Wen Hao Chuang added a comment - Is this related to MDL-10882 ? Penny do you have any update on this? Many thanks
Hide
Penny Leach added a comment -

I don't think it's related to this but they're both around silent stuff. I haven't had a chance to have a look at this bug yet

Show
Penny Leach added a comment - I don't think it's related to this but they're both around silent stuff. I haven't had a chance to have a look at this bug yet
Hide
Penny Leach added a comment -

Having a look at this issue (FINALLY!)

I'm a bit confused - is there supposed to be a restore_open_html in when you restore into an existing course? Or just when you're creating a new course?

Show
Penny Leach added a comment - Having a look at this issue (FINALLY!) I'm a bit confused - is there supposed to be a restore_open_html in when you restore into an existing course? Or just when you're creating a new course?
Hide
Eloy Lafuente (stronk7) added a comment -

uhm... that html file was introduced sometime ago by somebody from OU, mainly to log rolldates actions.

IMO it should be executed always, no matter if the course is being restored in silent mode or no, uhm... because the rolldates option works also in silent restores... or not?

Ciao

Show
Eloy Lafuente (stronk7) added a comment - uhm... that html file was introduced sometime ago by somebody from OU, mainly to log rolldates actions. IMO it should be executed always, no matter if the course is being restored in silent mode or no, uhm... because the rolldates option works also in silent restores... or not? Ciao
Hide
Penny Leach added a comment -

Wow, I am out of touch, I don't know anything about rolldates actions.

Anyway, the issue isn't silent vs not silent, it's restore into new course vs restore into existing course.

Show
Penny Leach added a comment - Wow, I am out of touch, I don't know anything about rolldates actions. Anyway, the issue isn't silent vs not silent, it's restore into new course vs restore into existing course.
Hide
Tim Hunt added a comment -

The roll-forward feature is for when you are backing up and restoring a course to make a new copy for a new year. This particular feature goes through the course adjusting any dates to match the new start date.

Show
Tim Hunt added a comment - The roll-forward feature is for when you are backing up and restoring a course to make a new copy for a new year. This particular feature goes through the course adjusting any dates to match the new start date.
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 has become inactive and does not appear to affect 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 has become inactive and does not appear to affect a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Dates

  • Created:
    Updated:
    Resolved: