Vtiger_Module_Model->getRelatedModuleRecordIds() can include deleted records
I have some custom modules which have an n:n relationship. I have been chasing a very odd problem and have noticed that the function in the title doesn't include the deleted = 0
WHERE clause in the query. This has been generating extra rows in a list of results which was causing my problem.
If a related module record is deleted (but not removed from the recycle bin) the record's ID is not being removed from the crmentityrel table. It does when the record gets properly deleted but not until then.
Can I suggest adding:
$sql .= " AND vtiger_crmentity.deleted = 0";
Just before the line where the query is executed (Line #1458 in 6.4.0)