verbb / cp-nav

Control Panel Nav is a Craft CMS plugin to help manage your Control Panel navigation.
MIT License
130 stars 11 forks source link

ErrorException: Warning: count(): Parameter must be an array or an object that implements Countable #87

Closed jamesmacwhite closed 3 years ago

jamesmacwhite commented 3 years ago

Description

Captured via Sentry when loading the Craft CP. It would seem either $oldNavItems and/or $newNavItems might not be an array or integer in some cases and potentially needs to be more defensive before calling count?

Exception
ErrorException: Warning: count(): Parameter must be an array or an object that implements Countable
  File "/vendor/verbb/cp-nav/src/services/Service.php", line 91, in verbb\cpnav\services\Service::checkUpdatedNavItems
    if (count($oldNavItems) < count($newNavItems)) {
  File "/vendor/verbb/cp-nav/src/CpNav.php", line 97, in verbb\cpnav\CpNav::verbb\cpnav\{closure}
    $this->getService()->checkUpdatedNavItems($event);
  File "/vendor/yiisoft/yii2/base/Event.php", line 312, in yii\base\Event::trigger
    call_user_func($handler[0], $event);
  File "/vendor/yiisoft/yii2/base/Component.php", line 636, in yii\base\Component::trigger
    Event::trigger($this, $name, $event);
  File "/vendor/craftcms/cms/src/web/twig/variables/Cp.php", line 280, in craft\web\twig\variables\Cp::nav
    $this->trigger(self::EVENT_REGISTER_CP_NAV_ITEMS, $event);
engram-design commented 3 years ago

Fixed in 3.0.15

jamesmacwhite commented 3 years ago

Thank you!