No permission to add cases because permission check will always return 0 when I have no cases
I have enabled the CiviCase component. When trying to add a case I get the message "You do not have permission to access this case." Correct, I remember....I have to add the Case permissions in my CMS. After doing this, I continue to get the message "You do not have permission to access this case." even though I also get the message "Case succesfully added".
Inspecting the code the permission is checked in CRM_Case_Form_CaseView:
// Access check.
if (!CRM_Case_BAO_Case::accessCase($this->_caseID, FALSE)) {
CRM_Core_Error::statusBounce(ts('You do not have permission to access this case.'));
}
The called function CRM_Case_BAO_Case::accessCase will always return 0 (meaning FALSE) whenever I have no cases in my database yet:
try {
return (bool) civicrm_api3('Case', 'getcount', $params);
}
catch (CiviCRM_API3_Exception $e) {
// Lack of permissions will throw an exception
return FALSE;
}
So it seems that I can never add a case if I have no cases yet, or am I missing something?
This is on CiviCRM 5.16.2