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

Fatal Error when backing up/restoring backup file created from empty course

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.3, 2.1, 2.2
    • Fix Version/s: 2.0.4, 2.1.1
    • Component/s: Backup
    • Labels:
    • Testing Instructions:
      Hide

      IMPORTANT: It's critical to test this twice. Once under 20_STABLE and another under 21_STABLE (no need for master testing as far as solution is 100% the 21_STABLE one).

      1) Create a new course, fill in the course settings
      2) Don't add any new activities
      3) Backup course
      4) Attempt to restore the course
      5) TEST: No notices/warnings shown along the whole process (specially pages 1 and 3 in the restore process
      6) TEST: Restore ends OK and you get one 100% empty (no activities) course at the end

      Show
      IMPORTANT: It's critical to test this twice. Once under 20_STABLE and another under 21_STABLE (no need for master testing as far as solution is 100% the 21_STABLE one). 1) Create a new course, fill in the course settings 2) Don't add any new activities 3) Backup course 4) Attempt to restore the course 5) TEST: No notices/warnings shown along the whole process (specially pages 1 and 3 in the restore process 6) TEST: Restore ends OK and you get one 100% empty (no activities) course at the end
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      restore_gradebook_in_or_equal_master

      Description

      I created a backup file from a course with nothing in it (see attached files), then got:

      Coding error detected, it must be fixed by a programmer: moodle_database::get_in_or_equal() does not accept empty arrays

      More information about this error

      Stack trace:
      line 582 of /lib/dml/moodle_database.php: coding_exception thrown
      line 326 of /backup/moodle2/restore_stepslib.php: call to moodle_database->get_in_or_equal()
      line 359 of /backup/util/plan/restore_structure_step.class.php: call to restore_gradebook_structure_step->after_execute()
      line 108 of /backup/util/plan/restore_structure_step.class.php: call to restore_structure_step->launch_after_execute_methods()
      line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
      line 148 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
      line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
      line 302 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
      line 144 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
      line 45 of /backup/restore.php: call to restore_ui->execute()

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            adriel Adriel added a comment - - edited
            Show
            adriel Adriel added a comment - - edited Here is a possible workaround until it's fixed: https://github.com/adriel/moodle/commit/46c3e7cf3ac34377a908b205f36dbc45f6b655d8
            Hide
            salvetore Michael de Raadt added a comment -

            When replicating this I saw some more errors during the process.

            At step 1 of the restore process, this was displayed:

            Notice: Undefined property: stdClass::$activities in D:\xampp\htdocs\moodle_testing\backup\util\ui\renderer.php on line 125
            Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\moodle_testing\backup\util\ui\renderer.php on line 125

            At step 3, this was displayed:

            Notice: Undefined property: stdClass::$activities in D:\xampp\htdocs\moodle_testing\backup\moodle2\restore_plan_builder.class.php on line 158
            Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\moodle_testing\backup\moodle2\restore_plan_builder.class.php on line 158

            After step 5, the errors above were given.

            Michael;

            Show
            salvetore Michael de Raadt added a comment - When replicating this I saw some more errors during the process. At step 1 of the restore process, this was displayed: Notice: Undefined property: stdClass::$activities in D:\xampp\htdocs\moodle_testing\backup\util\ui\renderer.php on line 125 Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\moodle_testing\backup\util\ui\renderer.php on line 125 At step 3, this was displayed: Notice: Undefined property: stdClass::$activities in D:\xampp\htdocs\moodle_testing\backup\moodle2\restore_plan_builder.class.php on line 158 Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\moodle_testing\backup\moodle2\restore_plan_builder.class.php on line 158 After step 5, the errors above were given. Michael;
            Hide
            vaughany Paul Vaughan added a comment -

            Just to confirm we're seeing this error on a course created in Moodle 2.0 (exact build unknown), and being imported into a different Moodle running 2.1 (build 20110701).

            Show
            vaughany Paul Vaughan added a comment - Just to confirm we're seeing this error on a course created in Moodle 2.0 (exact build unknown), and being imported into a different Moodle running 2.1 (build 20110701).
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            Just confirmed it's one regression caused by MDL-27988 when empty (no grade items) restore operations are executed.

            I've some "work-in-progress" patches available here:

            Right now it only fixes the problem the error with get_in_or_equal. It would be great to have this tested both int 20_STABLE and 21_STABLE (no needed for master = 21_STABLE) ASAP. Cause: patches are different for those 2 stable branches.

            In the mean time I'll be working on keeping out those notices (far less critical than the original error).

            So any feedback of the patches above (20 and 21 branches) will be really welcome.

            TIA and ciao

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - Just confirmed it's one regression caused by MDL-27988 when empty (no grade items) restore operations are executed. I've some "work-in-progress" patches available here: master: https://github.com/stronk7/moodle/compare/master...restore_gradebook_in_or_equal_master 21_STABLE: https://github.com/stronk7/moodle/compare/MOODLE_21_STABLE...restore_gradebook_in_or_equal_m21 20_STABLE: https://github.com/stronk7/moodle/compare/MOODLE_20_STABLE...restore_gradebook_in_or_equal_m20 Right now it only fixes the problem the error with get_in_or_equal. It would be great to have this tested both int 20_STABLE and 21_STABLE (no needed for master = 21_STABLE) ASAP. Cause: patches are different for those 2 stable branches. In the mean time I'll be working on keeping out those notices (far less critical than the original error). So any feedback of the patches above (20 and 21 branches) will be really welcome. TIA and ciao
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            Ho Adriel, just to ACK I discovered your proposal/patch NOW, while going to fix the notices commented above by Michael!

            It's 99% the same I'm doing, only tiny difference is the value you pass to get_in_or_equal(). I'm passing 0, impossible match, while you are passing true, aka numeric 1, improbable but possible (id = 1) match.

            Also note the 20_STABLE solution uses a different approach because such functionality is not available in the get_in_or_equal() function,

            Thanks for the patch, anyway! Going to kill those notices here... ciao

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - Ho Adriel, just to ACK I discovered your proposal/patch NOW, while going to fix the notices commented above by Michael! It's 99% the same I'm doing, only tiny difference is the value you pass to get_in_or_equal(). I'm passing 0, impossible match, while you are passing true, aka numeric 1, improbable but possible (id = 1) match. Also note the 20_STABLE solution uses a different approach because such functionality is not available in the get_in_or_equal() function, Thanks for the patch, anyway! Going to kill those notices here... ciao
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            Hi,

            I've added one more commit to the 3 branches above that cause all notices to disappear. So I'm sending this for integrations. In any case, feedback will be welcome an surely will make tester life easier.

            TIA and ciao

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - Hi, I've added one more commit to the 3 branches above that cause all notices to disappear. So I'm sending this for integrations. In any case, feedback will be welcome an surely will make tester life easier. TIA and ciao
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Thanks Eloy - all looked good and has been integrated now

            Show
            samhemelryk Sam Hemelryk added a comment - Thanks Eloy - all looked good and has been integrated now
            Hide
            andyjdavis Andrew Davis added a comment -

            Looks good

            Show
            andyjdavis Andrew Davis added a comment - Looks good
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Congratulations - this fix has just been released in the weeklies.

            Show
            samhemelryk Sam Hemelryk added a comment - Congratulations - this fix has just been released in the weeklies.

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  1/Aug/11