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

Backup error: invalid input syntax for integer: "" during restore of multianswer question

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Prerequisites

      1. In any Moodle <= 2.9
      2. Create a quiz in a new course
      3. Populate the quiz with a few Cloze questions
      4. In the database, change mdl_question_multianswer:sequence of B and D to respectively empty and ,,,.
      5. Backup your course

      Test

      1. Restore the backup
      2. Confirm that the restore finished without error
      3. Confirm that the backup logs informs you that the multianswer questions B and D had an invalid sequence
      4. Confirm that the other questions did not generate a notice in the logs
      Show
      Prerequisites In any Moodle <= 2.9 Create a quiz in a new course Populate the quiz with a few Cloze questions https://docs.moodle.org/29/en/Embedded_Answers_%28Cloze%29_question_type A, B with only one embedded question (the sequence will not contain any comma) C, D with more than one embedded question (the sequence will contain comma) In the database, change mdl_question_multianswer:sequence of B and D to respectively empty and ,,, . Backup your course Test Restore the backup Confirm that the restore finished without error Confirm that the backup logs informs you that the multianswer questions B and D had an invalid sequence Confirm that the other questions did not generate a notice in the logs
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_27_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE, MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-35987-master
    • Sprint:
      3.2 Sprint 1

      Description

      After performing a restore on a course I am receiving the following error:

      Default exception handler: Error reading from database Debug: ERROR:  invalid input syntax for integer: ""
      SELECT * FROM mdl_backup_ids_temp WHERE backupid = $1 AND itemname = $2 AND itemid = $3
       [array (
         0 => 'ecdcf30e7a1ffa5d5b41821d95f9b7d4',
         1 => 'question',
         2 => '',
       )]
       * line 396 of /lib/dml/moodle_database.php: dml_read_exception thrown
       * line 232 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
       * line 681 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
       * line 1296 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_records_sql()
       * line 1268 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
       * line 1248 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
       * line 1259 of /backup/util/dbops/restore_dbops.class.php: call to moodle_database->get_record()
       * line 213 of /backup/util/plan/restore_structure_step.class.php: call to restore_dbops::get_backup_ids_record()
       * line 205 of /backup/util/plan/restore_structure_step.class.php: call to restore_structure_step->get_mapping()
       * line 199 of /backup/moodle2/restore_plugin.class.php: call to restore_structure_step->get_mappingid()
       * line 108 of /question/type/multianswer/backup/moodle2/restore_qtype_multianswer_plugin.class.php: call to restore_plugin->get_mappingid()
       * line 79 of /backup/moodle2/restore_plugin.class.php: call to restore_qtype_multianswer_plugin->after_execute_question()
       * line 355 of /backup/util/plan/restore_structure_step.class.php: call to restore_plugin->launch_after_execute_methods()
       * 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 146 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 315 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
       * line 63 of /batchrestore/autorestore.php: call to restore_controller->execute_plan()
       * line 90 of /batchrestore/batchrestore20.php: call to restore_course()

      The error is a duplicate of http://tracker.moodle.org/browse/MDL-26587 but is in reference to the multianswer not the short answer like the original ticket is. However the fix is the same just needs to be applied to a different file. The version I am using is 2.1.6 but the issue seems to be in all version up to and including 2.3.X.

      I have tested this and here is a link to my commit. This should cherry-pick cleanly to the MOODLE_22_STABLE and MOODLE_23_STABLE.
      https://github.com/mdikih/moodle/commit/23b51f8411070da65a24dac9436f09dcc04fda13

      Thank you.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              fred Frédéric Massart
              Reporter:
              mdikih Michael Wylde
              Peer reviewer:
              Tim Hunt
              Integrator:
              Andrew Nicols
              Tester:
              Rajesh Taneja
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              10 Vote for this issue
              Watchers:
              16 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Jul/16