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

Restoring a choice fails with several notices then a fatal error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Backup, Choice
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      Hi Eloy,

      I've assigned this to you rather than the default choice maintainer as I suspect it is a restore issue and I have no clue where to start looking for a solution.
      I'm presently working on the course import UI and have hit an snag while attempting to import a course with one choice into the an empty course.
      After getting the errors in my script I tried to replicate with a standard backup/restore and found I could.

      The problem arrises by following these steps:

      1. Create a new course.
      2. Don't assign anyone proceed to turn on editing.
      3. Create a choice, set some options and save.
      4. Start a backup of the course.
      5. Turn off all settings except filter, blocks, and activities.
      6. Proceed through and run the backup.
      7. When the backup finished and you see the restorefile.php screen select your backup for restore.
      8. Proceed through the restore choosing merge into this course but not changing any other settings.
      9. When the restore executes you will get the notices and errors.

      The notices are as follows:

      Notice: Undefined property: stdClass::$id in /var/www/moodle/m20_dev1/moodle/mod/choice/backup/moodle2/restore_choice_stepslib.php on line 54
      Notice: Undefined property: stdClass::$timeopen in /var/www/moodle/m20_dev1/moodle/mod/choice/backup/moodle2/restore_choice_stepslib.php on line 57
      Notice: Undefined property: stdClass::$timeclose in /var/www/moodle/m20_dev1/moodle/mod/choice/backup/moodle2/restore_choice_stepslib.php on line 58
      Notice: Undefined property: stdClass::$timemodified in /var/www/moodle/m20_dev1/moodle/mod/choice/backup/moodle2/restore_choice_stepslib.php on line 59

      and then

      Error writing to database

      Debug info: Field 'intro' doesn't have a default value
      INSERT INTO choice (course,timeopen,timeclose,timemodified) VALUES(?,?,?,?)
      [array (
      0 => 11,
      1 => NULL,
      2 => NULL,
      3 => NULL,
      )]
      Stack trace:

      • line 383 of /lib/dml/moodle_database.php: dml_write_exception thrown
      • line 718 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      • line 760 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
        .......

      I also call print_r on the $data object right before the notices and got the following objects:

      Debug
      stdClass Object
      (
      [id] => 8
      [name] => A simple choice
      [intro] => <p>This is a simple choice for a simple course.</p>
      <p> </p>
      <p>Please choose your favourite number:</p>
      [introformat] => 1
      [publish] => 0
      [showresults] => 0
      [display] => 0
      [allowupdate] => 0
      [limitanswers] => 0
      [timeopen] => 0
      [timeclose] => 0
      [timemodified] => 1281683845
      )

      Debug
      stdClass Object
      (
      [answers] =>

      )

      I'll try to look into this myself and will let you know if I get anywhere.
      Yell out if you'd like any more information.

      Cheers
      Sam

        Attachments

          Activity

            People

            • Assignee:
              stronk7 Eloy Lafuente (stronk7)
              Reporter:
              samhemelryk Sam Hemelryk
              Tester:
              Nobody
              Participants:
              Component watchers:
              Adrian Greeve, Mihail Geshoski, Peter Dias, Dan Marsden, Jake Dallimore, Jun Pataleta, Ryan Wyllie
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                24/Nov/10