From 2f0251bb19fea6b4b9d5966b5b09402fbddb9e1b Mon Sep 17 00:00:00 2001 From: heavygale Date: Sat, 3 Oct 2020 12:55:14 +0200 Subject: [PATCH] Fix for "Trying to access array offset on value of type bool" Proper check for success of query before accessing the result array. This notices occures if there's no custom mail-template for trafficmaxpercent_subject or trafficmaxpercent_mailbody for the required language. --- lib/Froxlor/Cron/Traffic/ReportsCron.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Froxlor/Cron/Traffic/ReportsCron.php b/lib/Froxlor/Cron/Traffic/ReportsCron.php index 5019e519..bd24d0ac 100644 --- a/lib/Froxlor/Cron/Traffic/ReportsCron.php +++ b/lib/Froxlor/Cron/Traffic/ReportsCron.php @@ -15,7 +15,7 @@ namespace Froxlor\Cron\Traffic; * @author Froxlor team (2010-) * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @package Cron - * + * */ use Froxlor\Database\Database; use Froxlor\Settings; @@ -111,11 +111,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron 'varname' => 'trafficmaxpercent_subject' ); $result2 = Database::pexecute_first($result2_stmt, $result2_data); - $mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr)); + $mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr)); $result2_data['varname'] = 'trafficmaxpercent_mailbody'; $result2 = Database::pexecute_first($result2_stmt, $result2_data); - $mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr)); + $mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr)); $_mailerror = false; $mailerr_msg = ""; @@ -217,11 +217,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron 'varname' => 'trafficmaxpercent_subject' ); $result2 = Database::pexecute_first($result2_stmt, $result2_data); - $mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr)); + $mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr)); $result2_data['varname'] = 'trafficmaxpercent_mailbody'; $result2 = Database::pexecute_first($result2_stmt, $result2_data); - $mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr)); + $mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr)); $_mailerror = false; $mailerr_msg = ""; @@ -424,11 +424,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron 'varname' => 'diskmaxpercent_subject' ); $result2 = Database::pexecute_first($result2_stmt, $result2_data); - $mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr)); + $mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr)); $result2_data['varname'] = 'diskmaxpercent_mailbody'; $result2 = Database::pexecute_first($result2_stmt, $result2_data); - $mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr)); + $mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr)); $_mailerror = false; $mailerr_msg = ""; @@ -521,11 +521,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron 'varname' => 'diskmaxpercent_subject' ); $result2 = Database::pexecute_first($result2_stmt, $result2_data); - $mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr)); + $mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr)); $result2_data['varname'] = 'diskmaxpercent_mailbody'; $result2 = Database::pexecute_first($result2_stmt, $result2_data); - $mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr)); + $mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr)); $_mailerror = false; $mailerr_msg = "";