Dear all,
I got an issue (warning) on my monthly calender and AI support confirmed what I read from the source:
Warning: Undefined variable $icalrows in /components/com_jevents/libraries/datamodel.php on line 298
Version: 3.6.102 on Joomla 6.2
The issue is that $ icalrows is only assigned inside the if (! $ veryshort) branch, but it is used afterward in all cases:
$data['rows'] = $icalrows;
When $ veryshort is true, only $ rows is initialized:
else
{
$rows = array();
}
As a result, $ icalrows is undefined. This may trigger a PHP warning, and $ data['rows'] will not be set reliably.
Simple fix
Initialize both variables before the condition, then assign $data['rows'] afterward:
$icalrows = array();
$rows = array();
if (!$veryshort)
{
$icalrows = $this->queryModel->listIcalEventsByMonth($year, $month);
$rows = array_merge($icalrows, $rows);
}
$data['rows'] = $rows;
$rowcount = count($rows);
This ensures that:
When $ veryshort === true, both $ rows and $ data['rows'] are empty arrays.
Otherwise, $ data['rows'] contains the calendar events returned by the query.
The existing fallback:
if (!isset($icalrows)) $icalrows = array();
does not help in the veryshort case because it is inside the if (!$veryshort) branch.