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

Restore with Merge and section_format_options fails to restore

XMLWordPrintable

    • MOODLE_25_STABLE, MOODLE_28_STABLE
    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • wip-MDL-47337-master
    • Hide

      1. Create a course in a format that uses course_format_options for storing section information.
      I have put up an altered version of the topics format that adds this to demonstrate. https://github.com/mr-russ/moodle/compare/master...section_format_option
      2. Create a course using the new topics format, change some section options
      3. Backup the course.
      4. Change section options again
      5. Restore the course by selecting "Merge into course" options. So you are merging the course back into itself.
      6. Make sure there are no errors and section options are not overridden with ones from the backup
      7. Restore the same course as new course, make sure the section options are restored
      8. Restore the same course into the course in another format, make sure table course_format_options for this course does not have any records with non-empty sectionid

      Show
      1. Create a course in a format that uses course_format_options for storing section information. I have put up an altered version of the topics format that adds this to demonstrate. https://github.com/mr-russ/moodle/compare/master...section_format_option 2. Create a course using the new topics format, change some section options 3. Backup the course. 4. Change section options again 5. Restore the course by selecting "Merge into course" options. So you are merging the course back into itself. 6. Make sure there are no errors and section options are not overridden with ones from the backup 7. Restore the same course as new course, make sure the section options are restored 8. Restore the same course into the course in another format, make sure table course_format_options for this course does not have any records with non-empty sectionid

      Issue;

      When you attempt to merge a backup into an existing course that contains section_format_options you receive an error that there is a duplicate key. It should restore successfully. This is happening on 2.5.3 and also master.

      Debug info: ERROR: duplicate key value violates unique constraint "mdl_26_courformopti_coufor_uix"
      DETAIL: Key (courseid, format, sectionid, name)=(25, topics, 914, numdaystocomplete) already exists.
      INSERT INTO mdl_26_course_format_options (format,name,value,sectionid,courseid) VALUES($1,$2,$3,$4,$5) RETURNING id
      [array (
      'format' => 'topics',
      'name' => 'numdaystocomplete',
      'value' => '10',
      'sectionid' => '914',
      'courseid' => 25,
      )]
      Error code: dmlwriteexception
      Stack trace:
      line 446 of /lib/dml/moodle_database.php: dml_write_exception thrown
      line 244 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      line 868 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      line 924 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()
      line 1472 of /backup/moodle2/restore_stepslib.php: call to pgsql_native_moodle_database->insert_record()
      line 137 of /backup/util/plan/restore_structure_step.class.php: call to restore_section_structure_step->process_course_format_options()
      line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
      line 151 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
      line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
      line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
      line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
      line 190 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
      line 278 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
      line ? of unknownfile: call to progressive_parser->end_tag()
      line 179 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
      line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
      line 110 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
      line 181 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
      line 98 of /backup/moodle2/restore_section_task.class.php: call to base_task->execute()
      line 177 of /backup/util/plan/base_plan.class.php: call to restore_section_task->execute()
      line 167 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
      line 333 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
      line 184 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
      line 107 of /backup/restore.php: call to restore_ui->execute()
      

      How to reproduce;
      1. A course format that uses course_format_options for storing section information.
      I have put up an altered version of the topics format that adds this to demonstrate. https://github.com/mr-russ/moodle/compare/master...section_format_option
      2. Create a course using the new topics format.
      3. Backup the course.
      4. Immediately restore the course by selecting "Merge into course" options. So you are merging the course back into itself.
      5. You will receive a duplicate key error about inserting into the database.

      The course should restore without a problem.

      Questions:
      *What section_format_option should be used? The new one or the existing one in this case.
      *I've not tested restoring a single activity in a section, it may exhibit the same behaviour, if it does what section_format_option value should be used in that case and how do you tell the difference?

      Interesting git commit;

      commit 0360443020ebafd3cd9ff96bd861481924b4d77c
      Author: Marina Glancy <marina@moodle.com>
      Date:   Thu Oct 11 16:03:15 2012 +0800
       
          MDL-35768 Backup and restore of section format-specific options
      

      The above commit introduced the backup and restore of format information. It just doesn't seem to track merging correctly. This is likely due to the fact that no core course format uses section_format_options.

      I am happy to build a patch for this, however I don't know how best to answer the questions I've raised. And the implementation of a fix depends on answering them. Any input from other developers on this would be appreciated.

            marina Marina Glancy
            mr-russ Russell Smith
            Dan Poltawski Dan Poltawski
            Adrian Greeve Adrian Greeve
            Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.