No protection against undefined array offsets gives PHP warnings
Created by: webmaster-cses-org-uk
In a few places in GrantBase.php
, undefined array offsets (or uninitialised array variables) are referred to, causing our log file to fill up with many warnings / notices of the following nature:
[Sun Jul 03 20:49:18.226858 2022] [fcgid:warn] [pid 124034] [client 172.98.68.39:46520] mod_fcgid: stderr: PHP Notice: Trying to access array offset on value of type null in /home/cses_org_uk/public_html/media/civicrm/ext/biz.jmaconsulting.grantapplications/CRM/Grant/Form/GrantBase.php on line 159, referer: https://www.google.com/
[Sun Jul 03 20:49:18.228056 2022] [fcgid:warn] [pid 124034] [client 172.98.68.39:46520] mod_fcgid: stderr: PHP Notice: Trying to access array offset on value of type null in /home/cses_org_uk/public_html/media/civicrm/ext/biz.jmaconsulting.grantapplications/CRM/Grant/Form/GrantBase.php on line 160, referer: https://www.google.com/
[Sun Jul 03 20:49:18.228079 2022] [fcgid:warn] [pid 124034] [client 172.98.68.39:46520] mod_fcgid: stderr: PHP Notice: Undefined index: html_type in /home/cses_org_uk/public_html/media/civicrm/ext/biz.jmaconsulting.grantapplications/CRM/Grant/Form/GrantBase.php on line 359, referer: https://www.google.com/
[Sun Jul 03 20:49:18.228087 2022] [fcgid:warn] [pid 124034] [client 172.98.68.39:46520] mod_fcgid: stderr: PHP Notice: Undefined index: html_type in /home/cses_org_uk/public_html/media/civicrm/ext/biz.jmaconsulting.grantapplications/CRM/Grant/Form/GrantBase.php on line 386, referer: https://www.google.com/
[Sun Jul 03 20:49:18.228093 2022] [fcgid:warn] [pid 124034] [client 172.98.68.39:46520] mod_fcgid: stderr: PHP Notice: Undefined index: html_type in /home/cses_org_uk/public_html/media/civicrm/ext/biz.jmaconsulting.grantapplications/CRM/Grant/Form/GrantBase.php on line 359, referer: https://www.google.com/
[Sun Jul 03 20:49:18.228107 2022] [fcgid:warn] [pid 124034] [client 172.98.68.39:46520] mod_fcgid: stderr: PHP Notice: Undefined index: html_type in /home/cses_org_uk/public_html/media/civicrm/ext/biz.jmaconsulting.grantapplications/CRM/Grant/Form/GrantBase.php on line 386, referer: https://www.google.com/
A simple refactoring to use CRM_Utils_Array::value()
, as is already done in other places, fixes this.
PR to follow.