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