E_NOTICEs from CRM_Contribute_Task::permissionedTaskTitles() - undefined / null array errors
Not a major issue, but our log file is filling up with messages of the following nature:
[Thu Jul 14 13:28:43.516413 2022] [fcgid:warn] [pid 52056] [client 92.40.175.17:63990] mod_fcgid: stderr: PHP Notice: Undefined offset: 8 in /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Contribute/Task.php on line 190, referer: https://cses.org.uk/administrator/?option=com_civicrm&task=civicrm/event/search&reset=1&force=1&status=true&event=364
[Thu Jul 14 13:28:43.516486 2022] [fcgid:warn] [pid 52056] [client 92.40.175.17:63990] mod_fcgid: stderr: PHP Notice: Trying to access array offset on value of type null in /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Contribute/Task.php on line 190, referer: https://cses.org.uk/administrator/?option=com_civicrm&task=civicrm/event/search&reset=1&force=1&status=true&event=364
[Thu Jul 14 13:28:43.516486 2022] [fcgid:warn] [pid 52056] [client 92.40.175.17:63990] mod_fcgid: stderr: PHP Notice: Undefined offset: 9 in /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Contribute/Task.php on line 191, referer: https://cses.org.uk/administrator/?option=com_civicrm&task=civicrm/event/search&reset=1&force=1&status=true&event=364
[Thu Jul 14 13:28:43.516486 2022] [fcgid:warn] [pid 52056] [client 92.40.175.17:63990] mod_fcgid: stderr: PHP Notice: Trying to access array offset on value of type null in /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Contribute/Task.php on line 191, referer: https://cses.org.uk/administrator/?option=com_civicrm&task=civicrm/event/search&reset=1&force=1&status=true&event=364
[Thu Jul 14 13:28:43.516486 2022] [fcgid:warn] [pid 52056] [client 92.40.175.17:63990] mod_fcgid: stderr: PHP Notice: Undefined offset: 402 in /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Contribute/Task.php on line 190, referer: https://cses.org.uk/administrator/?option=com_civicrm&task=civicrm/event/search&reset=1&force=1&status=true&event=364
[Thu Jul 14 13:28:43.516486 2022] [fcgid:warn] [pid 52056] [client 92.40.175.17:63990] mod_fcgid: stderr: PHP Notice: Trying to access array offset on value of type null in /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Contribute/Task.php on line 192, referer: https://cses.org.uk/administrator/?option=com_civicrm&task=civicrm/event/search&reset=1&force=1&status=true&event=364
(Running CiviCRM 5.50.4)
The issue seems to be that in CRM_Contribute_Task::permissionedTaskTitles()
, there is a code path where the internal $_task
array is not initialised by calling the tasks()
method beforehand.
public static function permissionedTaskTitles($permission, $params = []) {
if (!isset($params['softCreditFiltering'])) {
$params['softCreditFiltering'] = FALSE;
}
if (($permission == CRM_Core_Permission::EDIT)
|| CRM_Core_Permission::check('edit contributions')
) {
$tasks = self::taskTitles();
}
else {
/*** ISSUE IS HERE - NO PRIOR CALL TO self::tasks() OR self::taskTitles() ETC ***/
$tasks = [
self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'],
self::TASK_EMAIL => self::$_tasks[self::TASK_EMAIL]['title'],
self::PDF_RECEIPT => self::$_tasks[self::PDF_RECEIPT]['title'],
];
//CRM-4418,
if (CRM_Core_Permission::check('delete in CiviContribute')) {
$tasks[self::TASK_DELETE] = self::$_tasks[self::TASK_DELETE]['title'];
}
}
if ($params['softCreditFiltering']) {
unset($tasks[self::BATCH_UPDATE], $tasks[self::PDF_RECEIPT]);
}
$tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params);
return $tasks;
}
Looks like a pretty easy fix (call self::tasks()
), but I need to do some further digging to be sure of the implications and think about how we would test this. Will have to pick this up again in a couple of weeks, but raising the issue now so it's on file.
If someone else comes in with a fix in the meantime, then great