Towards CRM-19815 make pseudoconstant handling more generic.
authoreileen <emcnaughton@wikimedia.org>
Thu, 23 Feb 2017 04:56:17 +0000 (17:56 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 24 Feb 2017 02:03:37 +0000 (15:03 +1300)
commit86ab13b72d6bcf45d1f663ecfb29d04320ed66f1
treefc37d4b8ca51003f3a73a339e8b208ba4b1bf832
parent916e58354ac998d70f436895db4b2e56e8b65caa
Towards CRM-19815 make pseudoconstant handling more generic.

Using metadata pseudoconstants we can remove joins on the option_value table, which hur performance. This patch
only opens it up within the context of the Contact table. It is intended to open the code up to
allow us to extend the performance advantage of dropping the bad join to other entities.

The following fields have metadata links to the
option_value table:
 gender_id
 prefix_id
 suffix_id
 preferred_communication_method
 communication_style_id
 preferred_language

The general pattern for the api is to return (eg) communication_style_id = 1, communication_style = 'Formal', where communication_style is the db name of the option group for communication_style_id.

preferred_communication_method is the exception. For api calls it returns an array of ids like all other api calls.
However, it returns a string of names for non-api calls on that field, allowing us to avoid handling it in a number of other places.

I added tests to ensure no change on the api inputs & outputs and searched these fields through search builder & advanced
search + export. I also checked profile search listings. They are not using the convert routine & have some e-notices that
pre-existed, but no regression I could see.
CRM/Contact/BAO/Query.php
CRM/Contact/Selector.php
CRM/Export/BAO/Export.php
tests/phpunit/CRM/Contact/BAO/QueryTest.php
tests/phpunit/api/v3/ContactTest.php