I hit a bug (in a unit test) where a user without permissions to access custom data would do a
check_permissions api call followed by a check_permissions = 0 call. In the second call
custom fields were not returned
as they were already excluded from the cached key.
$cacheKeyString .= $export ? '_1' : '_0';
$cacheKeyString .= $status ? '_1' : '_0';
$cacheKeyString .= $search ? '_1' : '_0';
+ $cacheKeyString .= '_' . (bool) $checkPermissions;
//CRM-14501 it turns out that the impact of permissioning here is sometimes inconsistent. The field that
//calculates custom fields takes into account the logged in user & caches that for all users
//as an interim fix we will cache the fields by contact