relationship custom data creates duplicate relationship records
Several years back, a commit was implemented that checked relationship custom data when determining if two contacts had an existing relationship. If the custom data did not match, a new relationship between the two contacts was created. The commit is here: https://github.com/civicrm/civicrm-core/commit/6b28495231b5c42f42ef4c837b88042c17faba3e
I understand and appreciate the intent of the behavior, and agree that it may be legitimate to want multiple relationships of the same type between the same two contacts when custom data should represent distinct historical information. However, the behavior has some negative consequences.
In particular -- it effectively ensures duplicate relationships will be created if at any time you expose the current employer field to a frontend facing form. In that context, there is no way to know or set the relationship custom data. If the employee/employer already have a relationship with any custom data set, submitting the form will create a duplicate relationship (and it will be set as the current employer). If the existing relationship had permissioning set, or the custom data had importance in other areas of the system, this can have a very negative impact.
All that said, I'm not sure of the best solution. One option is to create a global setting where you can choose to check relationship custom fields or not check them. Another option is to ignore the check if the new relationship has no custom fields set. Actually -- from the comments in the existing code it looks like that was the intent, but it may not be working (see https://github.com/civicrm/civicrm-core/commit/e312bf627757145dfca7ee9fa60c7dda30d5aaf2).
Anyway, I wanted to get some input on what may be viewed as a preferred solution.