Check for Change Case Type in case activity form doesn't do anything
This isn't the thing I was looking to fix but it came up and visually/review-wise it might be easier to deal with this first.
There's a couple things wrong in this block https://github.com/civicrm/civicrm-core/blob/5.23.2/CRM/Case/Form/Activity.php#L150-L157:
if (empty($caseTypes) && ($this->_activityTypeName == 'Change Case Type') && !$this->_caseId) {
$url = CRM_Utils_System::url('civicrm/contact/view/case',
"reset=1&action=view&cid={$this->_currentlyViewedContactId}&id={$caseIds}&show=1"
);
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
CRM_Core_Error::statusBounce(ts("You do not have any active Case Types"));
}
- It's really unlikely to ever trigger. In fact I'm not sure how to make it because of the
!$this->_caseId
part. I looked back and it was added here but I think they meant!empty($this->_caseId)
because$this->_caseId
is used in the very next line (since replaced by $caseIds but it's ultimately the same thing if you look at line 130).- So a corollary to that is that the url in the next line will have the
id=
have a blank value.
- So a corollary to that is that the url in the next line will have the
- Even if it were to trigger, it's comparing against label (activityTypeName is really label). While "Change Case Type" is something you're unlikely to change, it would never match for non-english.
- And while the overall intent of the check is not wrong and is better than a fatal error, I'm curious about the use-case where you've disabled all your case types but are still managing cases and wanting to change the type on a case. It obviously hasn't come up much in almost 10 years. But that's more of a sidenote.