Rationalise relationship validation
authorEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 12 Jan 2022 21:32:13 +0000 (10:32 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 13 Jan 2022 05:32:28 +0000 (18:32 +1300)
commitdead2d663e4e8beacb7fc37362e0db31afed6009
tree5a096b6507cd4e8c1fbbfbfe7b4407cdf240c1b7
parentf00a0870bf369b1182b3310ee9d3ab80018c4c0c
Rationalise relationship validation

The previous relationship validation was
1) throw a message is no valid employer relationship - this seems to be done
in a place that would make the site unusable I've centralised this check into a
cached function that gets the id & throws the exception & is used from
places previously fetching it (there is one that
didn't throw an exception previously but I think enough places did
that extending to that place would not break the site any more if it didn't exist

2) complicated look up to determine if the contact types match the relationship's
expectations. Since we already know the relationship's expectations we
can simplify this to just check contact a is an individual and b is an org which is
much more reasonable. It doesn;t seem like this would ever actually be false so
I added a deprecation to be a bit vocal if it is
CRM/Contact/BAO/Contact/Utils.php
CRM/Contact/BAO/Relationship.php
CRM/Contact/BAO/RelationshipType.php
CRM/Contribute/Form/Contribution/Confirm.php
tests/phpunit/api/v3/ContactTest.php