craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
225 stars 170 forks source link

[5.x]: Permission group setup results in error "Call to a member function getStore() on null" when accessing dashboard #3732

Open romainpoirier opened 11 hours ago

romainpoirier commented 11 hours ago

What happened?

Description:

I am trying to configure a permission group for administrators who should only have access to Craft Commerce orders and the users linked to those orders.

Here is the permission group configuration I defined:

General:

Craft Commerce:

After logging in, the administrators encounter the following error when trying to access the dashboard:

Error: Call to a member function getStore() on null in /var/www/html/vendor/craftcms/commerce/src/widgets/AverageOrderTotal.php:50
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\commerce\widgets\AverageOrderTotal->init()
#1 /var/www/html/vendor/craftcms/cms/src/base/Model.php(87): yii\base\BaseObject->__construct()
#2 [internal function]: craft\base\Model->__construct(Array)
#3 /var/www/html/vendor/yiisoft/yii2/di/Container.php(411): ReflectionClass->newInstanceArgs(Array)
#4 /var/www/html/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('craft\\commerce\\...', Array, Array)
#5 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('craft\\commerce\\...', Array, Array)
#6 /var/www/html/vendor/craftcms/cms/src/Craft.php(70): yii\BaseYii::createObject(Array, Array)
#7 /var/www/html/vendor/craftcms/cms/src/helpers/Component.php(142): Craft::createObject(Array)
#8 /var/www/html/vendor/craftcms/cms/src/services/Dashboard.php(129): craft\helpers\Component::createComponent(Array, 'craft\\base\\Widg...')
#9 /var/www/html/vendor/craftcms/cms/src/controllers/DashboardController.php(75): craft\services\Dashboard->createWidget(Array)
#10 [internal function]: craft\controllers\DashboardController->actionIndex()
#11 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#13 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('index', Array)
#14 /var/www/html/vendor/craftcms/cms/src/web/Application.php(350): yii\base\Module->runAction('dashboard/index', Array)
#15 /var/www/html/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('dashboard/index', Array)
#16 /var/www/html/vendor/craftcms/cms/src/web/Application.php(318): yii\web\Application->handleRequest(Object(craft\web\Request))
#17 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#18 /var/www/html/htdocs/index.php(12): yii\base\Application->run()
#19 {main}

Is the current permission group setup sufficient to achieve the expected behavior?

Steps to reproduce

  1. Configure the permissions as listed above.
  2. Log in as an administrator.
  3. Attempt to access the dashboard.

Expected behavior

Administrators should only have access to orders and related users without any errors.

Actual behavior

The following error is thrown upon accessing the dashboard:
Call to a member function getStore() on null in /var/www/html/vendor/craftcms/commerce/src/widgets/AverageOrderTotal.php:50.

Craft CMS version

5.4.8

Craft Commerce version

5.1.3

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

No response

linear[bot] commented 11 hours ago

PT-2262 [5.x]: Permission group setup results in error "Call to a member function getStore() on null" when accessing dashboard