From d462a4a538213cd140c22a85158bb5c9f267cd3f Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Wed, 31 Aug 2022 17:33:04 +0100 Subject: [PATCH] Stop PHP warning on installations with no contributions --- CRM/Contribute/BAO/Contribution/Utils.php | 4 ++-- CRM/Contribute/Form/ContributionCharts.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index b34b1e7daf..c14439d7ab 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -22,7 +22,7 @@ class CRM_Contribute_BAO_Contribution_Utils { * @param int $param * Year. * - * @return array + * @return array|null * associated array */ public static function contributionChartMonthly($param) { @@ -61,7 +61,7 @@ INNER JOIN civicrm_contact AS contact ON ( contact.id = contrib.contact_id ) /** * Get the contribution details by year. * - * @return array + * @return array|null * associated array */ public static function contributionChartYearly() { diff --git a/CRM/Contribute/Form/ContributionCharts.php b/CRM/Contribute/Form/ContributionCharts.php index 33822e5063..5b2005f746 100644 --- a/CRM/Contribute/Form/ContributionCharts.php +++ b/CRM/Contribute/Form/ContributionCharts.php @@ -118,7 +118,7 @@ class CRM_Contribute_Form_ContributionCharts extends CRM_Core_Form { $chartInfoYearly = CRM_Contribute_BAO_Contribution_Utils::contributionChartYearly(); //get the years. - $this->_years = $chartInfoYearly['By Year']; + $this->_years = $chartInfoYearly['By Year'] ?? []; $hasContributions = FALSE; if (is_array($chartInfoYearly)) { $hasContributions = TRUE; -- 2.25.1