mlutfy / reporterror

Sends you a detailed email when a CiviCRM fatal error occurs.
https://lab.civicrm.org/extensions/reporterror
9 stars 7 forks source link

PHP Notice - Undefined Index on title #23

Closed arborrow closed 7 years ago

arborrow commented 7 years ago

I am attending CiviCon STL devtraining and was looking for an extension that does exactly what you have implemented so first many thanks for making this available. When I installed on my dev server, I discovered that in CRM/Admin/Form/Setting/ReportError.php I was getting a few:

Notice: Undefined index: title in CRM_Admin_Form_Setting_ReportError->buildQuickForm() (line 103 of /home/anthony/buildkit/build/devtraining/sites/default/files/civicrm/ext/ca.bidon.reporterror/CRM/Admin/Form/Setting/ReportError.php).

This is when building out the event page drop down. Apparently, there are some events with no title (which is another issue that I am curious about and will follow up on. Nevertheless, I thought it might be good to check if the value is defined before using it and figured I would create that issue.

Essentially I just added to both the contributions page and events foreach loops:

if(!isset($val['title'])) {
            $val['title'] = ''; //initialize title
        } 
mlutfy commented 7 years ago

Hi @arborrow, thanks for reporting this!

I applied a patch that should fix the issue. Could you test the latest 'master' branch?

I'm at the St Louis sprint if you'd like to chat.

arborrow commented 7 years ago

I went first to disable and then uninstall the extension. During uninstall I received: DB Error: no such field Error Details Database Error Code: Unknown column 'group_name' in 'where clause', 1054 Additional Details:

Array ( [callback] => Array ( [0] => CRM_Core_Error [1] => handle )

[code] => -19
[message] => DB Error: no such field
[mode] => 16
[debug_info] => DELETE FROM civicrm_setting WHERE group_name = 'ReportError Extension' [nativecode=1054 ** Unknown column 'group_name' in 'where clause']
[type] => DB_Error
[user_info] => DELETE FROM civicrm_setting WHERE group_name = 'ReportError Extension' [nativecode=1054 ** Unknown column 'group_name' in 'where clause']
[to_string] => [db_error: message="DB Error: no such field" code=-19 mode=callback callback=CRM_Core_Error::handle prefix="" info="DELETE FROM civicrm_setting WHERE group_name = 'ReportError Extension' [nativecode=1054 ** Unknown column 'group_name' in 'where clause']"]

)

13 /home/anthony/buildkit/build/devtraining/sites/default/files/civicrm/ext/ca.bidon.reporterror/reporterror.php(62): CRM_Core_DAO::executeQuery("DELETE FROM civicrm_setting WHERE group_name = %1", (Array:1))

$sql = "DELETE FROM civicrm_setting WHERE group_name = %1";

doesn't look right to me but I am not all that familiar with Civi architecture to know for sure.

arborrow commented 7 years ago

That said, I did test the patch and it does remove the PHP notice. It was nice to learn about the CRM_Utils_Array class.

mlutfy commented 7 years ago

yep, that's the issue #21. I'll push a fix in a few minutes. Thanks for testing!