Logic hook can't find link name of relation

Hello All,

I'm looking for help with figuring out why a new logic hook works well on my local Sugar instance but does not work in the online instance. This is an after_save logic hook in the RevenueLineItems module that automatically creates/updates records in a custom module called BillingMilestones and then deletes unneeded BillingMilestone records. There is a one-to-many relationship between RevenueLineItems and BillingMilestones. There is also a one-to-many relationship between Opportunities and RevenueLineItems, and an after_save logic hook that updates RevenueLineItems with values from Opportunity on saving an Opportunity.


The new after_save hook that I'm working on is meant to create/update BillingMilestones on saving an Opportunity. This hook has several functions that create/update a BillingMilestone and one function that deletes unneeded BillingMilestones. The functions that create/update records work well. The problem occurs in the function that deletes unneeded records. The last two lines of this function are

$BillingMilestone->mark_deleted($BillingMilestone->id);

$BillingMilestone->save();


Using $GLOBALS['log'] statements, I see that mark_deleted() runs successfully, but an error is thrown during the execution of the save() statement. In the system log, the error shown immediately after mark_deleted() is "Could not find link name of relation ' ' ". I know that it is thrown during and not after the execution of save() because the save() function returns an id of the saved record, but using $GLOBALS['log']->fatal($tBillingMilestone->save()) does not output an id. When this happens, Error 500 is thrown in the browser. Running "Rebuild Relationships" does not help. This function is enclosed in a try-catch clause, which does not catch any exceptions. As I mentioned above, this never happens in the Sugar instance on my local machine.
What are the possible reasons why this error would be thrown?