We have a database of churches who are members of our organisation. People who are volunteers or employees of those churches also inherit membership by relationship. We are using a custom relationship type of 'Minister' to identify which individual related to each church is the lead vicar/minster/pastor/etc.
Some ministers are related to more than one church, and I am finding that the minister relationships are also causing memberships to inherit in the wrong direction. i.e. if a minister is with one member church, the membership will pass from the church to the minster, from the minister to any other churches they are with, and then on from those to every volunteer and employee of those churches as well.
The membership type table definitely only has the A to B (organisation to individual) relationship included. Why is the membership also passing the other way from individual to organisation?
Edit: Full walkthrough
I have two churches: St. Tests, and St. Joseph the Tester. Both share the same minster, Testy McTestface, but St. Josephs also has a couple of other volunteers. Neither church, nor any of their related contacts, have any memberships.
I add a Church membership to St. Tests:
A related membership is created for the minister contact, as expected:
But so is a membership for St. Josephs, the other church, through it's relationship to the minister of St. Tests.
And so are memberships for each of the additional volunteers associated with the second church:
Edit: Further screenshots in response to questions
Second degree relationship permissions are turned off.
These are all the CiviCRM extensions I have installed. I tried deleting the membership on the St. Tests example above (which, to confirm, also cleared all the others shown in the screenshots), disabling all these extensions, and then recreating the membership. The problem still occurred.
These are the only Drupal rules I have. I'm using CiviMember Roles Sync to add an 'active member' role to current members, and display a warning to anyone who's had their membership deactivated.
Edit: Some further testing
I tried changing the relationship type between the minister and the two churches from my custom Minister type to the built in Employer/Employee type, and the dodgy memberships persisted. In fact, the minister contact gained a second membership, one inherited from each of the churches he's employed by - even though only one has a membership of its own, and the second is inherited through the minster himself!
When I then went ahead and deleted the original membership all the memberships across all five contacts disappeared. Recreating it, on either church, behaves as expected. Now I'm using the built in Employee relationship type, memberships stay within their own organisation. So it looks like it is something to do with the relationship type, but I've no idea what! Can anyone replicate?