fix PHP 8.0 TypeError: Cannot access offset of type string on string, when iCal exporting a GEO attributes

This commit is contained in:
Ralf Becker 2021-11-10 16:59:47 +01:00
parent 519114ea1a
commit 2944a00e02
2 changed files with 42 additions and 3 deletions

View File

@ -871,6 +871,24 @@ class calendar_ical extends calendar_boupdate
{
$attr_name = 'X-EGROUPWARE-'.$attr_name;
}
// fix certain stock fields like GEO, which are not in EGroupware schema, but Horde Icalendar requires a certain format
switch($name)
{
case '##GEO':
if (!is_array($value))
{
if (strpos($value, ';'))
{
list($lat, $long) = explode(';', $value);
}
else
{
list($long, $lat) = explode(',', $value);
}
$value = ['latitude' => $lat, 'logitude' => $long];
}
break;
}
if ($value[0] === '{' && ($attr = json_decode($value, true)) && is_array($attr))
{
// check if attribute was stored compressed --> uncompress it

View File

@ -412,9 +412,30 @@ class infolog_ical extends infolog_bo
{
if (substr($name, 0, 2) == '##')
{
if (($v = json_php_unserialize($value)) && is_array($v))
{
$value = $v;
}
// fix certain stock fields like GEO, which are not in EGroupware schema, but Horde Icalendar requires a certain format
switch($name)
{
case '##GEO':
if (!is_array($value))
{
if (strpos($value, ';') !== false)
{
list($lat, $long) = explode(';', $value);
}
else
{
list($long, $lat) = explode(',', $value);
}
$value = ['latitude' => $lat, 'logitude' => $long];
}
break;
}
if ($name[2] == ':')
{
if (($v = json_php_unserialize($value)) && is_array($v)) $value = $v;
foreach((array)$value as $compvData)
{
$comp = Horde_Icalendar::newComponent(substr($name,3), $vevent);
@ -422,9 +443,9 @@ class infolog_ical extends infolog_bo
$vevent->addComponent($comp);
}
}
elseif (($attr = json_php_unserialize($value)) && is_array($attr))
elseif (is_array($value))
{
$vevent->setAttribute(substr($name, 2), $attr['value'], $attr['params'], true, $attr['values']);
$vevent->setAttribute(substr($name, 2), $value['value'], $value['params'], true, $value['values']);
}
else
{