Yes, I always do what you say. I have been managing a large moodle site for over 11 years with more than 7,000 courses and 25,000 users in addition to making my own developments using the moodle API.
As I commented in my previous post, this merger development has been running smoothly for several years until we have migrated to version 3.6.5
The disconcerting thing is that only in 10-20% of cases the code fails to add the metalinks. I have ruled out possible problems including the revision of API 3.2 and 3.6 of moodle to check if the functions, classes and parameters of the code used had changed but have not done so.