dev/translation#70 - Cache separate ContactType lists per-locale
authorTim Otten <totten@civicrm.org>
Fri, 27 Aug 2021 05:21:49 +0000 (22:21 -0700)
committerTim Otten <totten@civicrm.org>
Fri, 27 Aug 2021 05:50:30 +0000 (22:50 -0700)
commit3c33fb1690eeea7f49fdecf589436982b4ed4603
treeb1afc9c0615b6562a74ee10670451a55d42b5a9c
parent9600db63dd4c52cf2d8bc54706d33b8e80278353
dev/translation#70 - Cache separate ContactType lists per-locale

Notes:

* If you grep to see how `contactTypes` cache is used, it appears that they never
  access this row individually outside this function.
* There are coarse-grained `clear()` invocations all `contactTypes`-related data.
  These should hit the old+new keys the same way.
* I made the cache-lookup a little more micro-optimal. :shrug:

To verify that this fixes the bug, I enabled multilingual with fr_CA+es_MX and manually translated the labels for "Individual" contacts.
Then used the following command:

```
cv ev -U admin 'function go($l){ CRM_Core_I18n::singleton()->setLocale($l); return \Civi\Test\Invasive::call(["CRM_Contact_BAO_ContactType","getAllContactTypes"])["Individual"]; } return [go("fr_CA"),go("es_MX")];'
```

Before the patch, it returns the en_US labels ("Individual"..."Individual"...).

After the patch, it returns the fr_CA and es_MX labels that I had created ("Particulier"..."Persona"...).
CRM/Contact/BAO/ContactType.php