Home: Avoid "Illegal offset type" with default favorites from 21.1

This commit is contained in:
nathan 2023-03-17 10:46:12 -06:00
parent 4f40ef01da
commit b6fa739ee4

View File

@ -90,13 +90,14 @@ class home_favorite_portlet extends home_portlet
$favorites = Framework\Favorites::get_favorites($context['appname']); $favorites = Framework\Favorites::get_favorites($context['appname']);
} }
$this->favorite = (array)$favorites[$context['favorite'] ?: 'blank']; $this->favorite = is_array($context['favorite']) ? $context['favorite'] :
(array)$favorites[$context['favorite'] ?: 'blank'];
$this->title = lang($context['appname']) . ': ' . $this->favorite['name']; $this->title = lang($context['appname']) . ': ' . $this->favorite['name'];
$this->context = $context; $this->context = $context;
if($this->favorite) if($this->favorite)
{ {
$this->nm_settings['favorite'] = $this->context['favorite']; $this->nm_settings['favorite'] = $this->context['favorite'];
if(is_array($favorites[$context['favorite']]['state'])) if(is_string($context['favorite']) && is_array($favorites[$context['favorite']]['state']))
{ {
$this->nm_settings += $this->favorite['state']; $this->nm_settings += $this->favorite['state'];
} }