-
Bug
-
Resolution: Fixed
-
Minor
-
3.10.7, 3.11.3, 4.0
-
MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_400_STABLE
-
MOODLE_311_STABLE
-
This has been detected while testing MDL-72743
It seems that there is a (rare, coincidental, but real) issue in the code in charge of restoring the question categories and map them to the target course.
It happens when a contextid in the source course (coming in the backup file) matches the context of a existing contextid in the target course AND when both contexts belongs to the same course (or an activity in the same course).
Again, rare, yes, but 100% possible and reproducible. Also, while it has been possible to reproduce it with Oracle... the problem is the same for all databases.
The original details commented @ MDL-72743 follow, explaining the problem:
1) The backup file (that is 100% correct) comes with:
- a course, with original contextid 29.
- a quiz activity, with original context 31
2) Of course the 2 question categories at course level also have 29 and the quiz ones 31.
3) The test then creates a new course that is going to be the restore target.
4) That course, by absolutely crazy coincidence (we don't support random sequence seeds in Oracle), is created with contextid 31 in target site.
5) When restore perform the prechecks... it:
- picks the question categories at course level (originally with contextid 29), detects 2, and, correctly, decides that their target contextid is going to be 31 (the target course, how not.
- picks the question categories at activity level (originally with context 31), but it now detects incorrectly 4, because the previous step has updated the original 29s to 31s too.
- Of course, those 4 categories do include 2 top categories... so the precheck fails.
To reproduce it, just search codebase for MDL-72950, remove the skip test condition and, with Oracle, run vendor/bin/phpunit mod/quiz/tests/restore_attempt_test.php a few times.
- Discovered while testing
-
MDL-72743 Make question restore more fault tolerant of missing user data in course backups
-
- Closed
-