Merge branch 'MDL-82310-404' of https://github.com/ferranrecio/moodle into MOODLE_404_STABLE

This commit is contained in:
Sara Arjona
2024-07-09 08:54:54 +02:00
2 changed files with 5 additions and 13 deletions
+5 -2
View File
@@ -1629,8 +1629,11 @@ class restore_section_structure_step extends restore_structure_step {
$data, true);
}
}
$section->component = $data->component ?? null;
$section->itemid = $data->itemid ?? null;
// Moodle 4.4 implement basic delegated section logic but it is not able to restore
// them from a backup. To prevent unexpected retoration errors, all sections with
// a component will be restored as a normal section.
$section->component = null;
$section->itemid = null;
$newitemid = $DB->insert_record('course_sections', $section);
$section->id = $newitemid;
@@ -113,15 +113,6 @@ class restore_stepslib_test extends \advanced_testcase {
$this->setAdminUser();
$course = $this->getDataGenerator()->create_course(['numsections' => 2, 'format' => 'topics']);
// Section 2 has an existing delegate class.
course_update_section(
$course,
$DB->get_record('course_sections', ['course' => $course->id, 'section' => 2]),
[
'component' => 'test_component',
'itemid' => 1,
]
);
$backupid = $this->backup_course($course);
$newcourseid = $this->restore_replacing_content($backupid);
@@ -133,8 +124,6 @@ class restore_stepslib_test extends \advanced_testcase {
$validatefields = ['name', 'summary', 'summaryformat', 'visible', 'component', 'itemid'];
$this->assertEquals($originalsections[1]->name, $restoredsections[1]->name);
foreach ($validatefields as $field) {
$this->assertEquals($originalsections[1]->$field, $restoredsections[1]->$field);
$this->assertEquals($originalsections[2]->$field, $restoredsections[2]->$field);