Improve error handling for invalid counter properties on backend menu items

This commit is contained in:
Luke Towers 2020-06-19 23:54:44 -06:00
parent 1b8fae0ef0
commit ef36399cf7
1 changed files with 4 additions and 1 deletions

View File

@ -373,7 +373,7 @@ class NavigationManager
} }
} }
if (empty($item->counter)) { if (empty($item->counter) || !is_numeric($item->counter)) {
$item->counter = null; $item->counter = null;
} }
} }
@ -421,6 +421,9 @@ class NavigationManager
$item->counter = null; $item->counter = null;
} }
} }
if (!is_null($item->counter) && !is_numeric($item->counter)) {
throw new SystemException("The menu item {$activeItem->code}.{$item->code}'s counter property is invalid. Check to make sure it's numeric or callable. Value: " . var_export($item->counter, true));
}
} }
return $items; return $items;