which passes a course module to duplicate_module() of lib.php
lib.php then uses the course module as an argument for
- new backup_controller()
- new restore_controller()
So far, I have not found any loops.
The problem is NOT caused by DB->set_field(), otherwise users would complain of exponential growth on many other tables.
The symptom appears in the table, mdl_question.
When a quiz is duplicated multiple times,
each question in the quiz is appended to the table a number of times equal to 2^(n-1) , where n equals the number of duplicates created.
= (1 original quiz) + 4 duplicates
(the ID of 16 in my example is irrelevant)
More details about the symptom are beautifully described here: MDL-63260
The cause is clear, and already linked in the tracker. This is a 'regression' cauased by MDL-45851.
In fact, the MDL-45851 fix was right and necessary, it is just that it did not go far enough, and I have not yet thought about the best approach to solve it. Two possibilities:
- MDL-45851 change retore to duplicated all random questions, rather than ever risk reusing them. A hard but possibly more correct fix would be to change that logic to only duplicate questions if they are used.
- The alternative is to fix this somewhere other than in the backup/restore code. E.g. it would be easier, and would solve other problems too, to have a scheduled task to automatically delete random questions that are no longer used anywhere.
Thank you for clearing up my confusion about the regression.
A patch file is attached, or you can see the commits here: