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

Restore to new course failure notice if logged in as course creator

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: 1.6.3
    • Component/s: Backup
    • Labels:
      None
    • Environment:
      Linux
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_16_STABLE
    • Fixed Branches:
      MOODLE_16_STABLE

      Description

      If I attempt to restore the attached backup file whilst logged in as a course creator I get the following failure notice when restoring to create new course:

      An error has occurred and the restore could not be completed!

      Adding to an exiting course works fine.

      Both sites 1.6+

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            dougiamas Martin Dougiamas added a comment -

            From Daniele Cordella (d.cordella at iss.it) Wednesday, 12 July 2006, 01:59 PM:

            I saw a strange option during the process.

            Attached the screenshot.

            From Daniele Cordella (d.cordella at iss.it) Wednesday, 12 July 2006, 02:29 PM:

            I do confirm the the error but... in spite of the error notification... the course was restored.

            From Ray Lawrence (ray at howtomoodle.com) Wednesday, 12 July 2006, 11:03 PM:

            I've isolated this issue to the course creator not being a Teacher in the course being restored. Is this the expected behaviour or a bug?

            From paolo oprandi (paolo at sussex.ac.uk) Wednesday, 12 July 2006, 11:36 PM:

            Ray, I'd call it slightly buggy - the error message shouldn't be thrown. It is related to the bug I have filed:

            http://moodle.org/bugs/bug.php?op=show&bugid=6051&pos=6

            From Ray Lawrence (ray at howtomoodle.com) Wednesday, 12 July 2006, 11:39 PM:

            Thanks Paolo. I'm watching that bug too. Unfortunately I won't have time to do much more testing on this in the near future.

            Show
            dougiamas Martin Dougiamas added a comment - From Daniele Cordella (d.cordella at iss.it) Wednesday, 12 July 2006, 01:59 PM: I saw a strange option during the process. Attached the screenshot. From Daniele Cordella (d.cordella at iss.it) Wednesday, 12 July 2006, 02:29 PM: I do confirm the the error but... in spite of the error notification... the course was restored. From Ray Lawrence (ray at howtomoodle.com) Wednesday, 12 July 2006, 11:03 PM: I've isolated this issue to the course creator not being a Teacher in the course being restored. Is this the expected behaviour or a bug? From paolo oprandi (paolo at sussex.ac.uk) Wednesday, 12 July 2006, 11:36 PM: Ray, I'd call it slightly buggy - the error message shouldn't be thrown. It is related to the bug I have filed: http://moodle.org/bugs/bug.php?op=show&bugid=6051&pos=6 From Ray Lawrence (ray at howtomoodle.com) Wednesday, 12 July 2006, 11:39 PM: Thanks Paolo. I'm watching that bug too. Unfortunately I won't have time to do much more testing on this in the near future.
            Hide
            mixik Daniel Miksik added a comment -

            In my environment, the solution was to define the $USER constant as global at the beginning of the restore_execute() function:

            — ORIGINAL\backup\restorelib.php Tue Sep 19 13:54:26 2006
            +++ MODIFIED\backup\restorelib.php Wed Oct 04 15:39:34 2006
            @@ -4850,3 +4850,3 @@
            function restore_execute(&$restore,$info,$course_header,&$errorstr) {

            • global $CFG;
              + global $CFG, $USER;
              $status = true;

            Without this modification, the restore process finishes correctly (i.e. the whole course is properly restored), the only thing that is not completed is adding the current user as a teacher to the newly created course:

            line 5355: $status = add_teacher($USER->id, $restore->course_id);

            as the $USER->id is not available to it.

            Show
            mixik Daniel Miksik added a comment - In my environment, the solution was to define the $USER constant as global at the beginning of the restore_execute() function: — ORIGINAL\backup\restorelib.php Tue Sep 19 13:54:26 2006 +++ MODIFIED\backup\restorelib.php Wed Oct 04 15:39:34 2006 @@ -4850,3 +4850,3 @@ function restore_execute(&$restore,$info,$course_header,&$errorstr) { global $CFG; + global $CFG, $USER; $status = true; Without this modification, the restore process finishes correctly (i.e. the whole course is properly restored), the only thing that is not completed is adding the current user as a teacher to the newly created course: line 5355: $status = add_teacher($USER->id, $restore->course_id); as the $USER->id is not available to it.
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            Hi Daniel,

            it seems to have sense, so I've applied your suggestion to 1.6! Thanks!

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - Hi Daniel, it seems to have sense, so I've applied your suggestion to 1.6! Thanks!

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Oct/06