Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getDataSourceTypes method throws exception when $currentUser is null. #327

Open
webrgp opened this issue Aug 7, 2024 · 0 comments
Open

Comments

@webrgp
Copy link

webrgp commented Aug 7, 2024

Description

While testing Verbb's Zen plugin, I've ran into this issue trying to import users previously exported by the same plugin. Here is the full stack track from the queue.log:

2024-08-07 12:06:22 [queue.ERROR] [Exception] Exception: Error: Call to a member function can() on null in /var/www/vendor/barrelstrength/sprout/src/datastudio/datasources/DataSources.php:76
Stack trace:
#0 [internal function]: BarrelStrength\Sprout\datastudio\datasources\DataSources::BarrelStrength\Sprout\datastudio\datasources\{closure}('BarrelStrength\\...')
#1 /var/www/vendor/barrelstrength/sprout/src/datastudio/datasources/DataSources.php(77): array_filter(Array, Object(Closure))
#2 /var/www/vendor/barrelstrength/sprout/src/datastudio/DataStudioModule.php(286): BarrelStrength\Sprout\datastudio\datasources\DataSources->getDataSourceTypes()
#3 /var/www/vendor/barrelstrength/sprout/src/datastudio/DataStudioModule.php(161): BarrelStrength\Sprout\datastudio\DataStudioModule->getUserPermissions()
#4 [internal function]: BarrelStrength\Sprout\datastudio\DataStudioModule->BarrelStrength\Sprout\datastudio\{closure}(Object(craft\events\RegisterUserPermissionsEvent))
#5 /var/www/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Object(Closure), Object(craft\events\RegisterUserPermissionsEvent))
#6 /var/www/vendor/yiisoft/yii2/base/Component.php(650): yii\base\Event::trigger('craft\\services\\...', 'registerPermiss...', Object(craft\events\RegisterUserPermissionsEvent))
#7 /var/www/vendor/craftcms/cms/src/services/UserPermissions.php(107): yii\base\Component->trigger('registerPermiss...', Object(craft\events\RegisterUserPermissionsEvent))
#8 /var/www/vendor/craftcms/cms/src/services/UserPermissions.php(768): craft\services\UserPermissions->getAllPermissions()
#9 /var/www/vendor/craftcms/cms/src/services/UserPermissions.php(292): craft\services\UserPermissions->_filterOrphanedPermissions(Array, Array)
#10 /var/www/vendor/verbb/zen/src/elements/User.php(244): craft\services\UserPermissions->saveUserPermissions(7455777, Array)
#11 /var/www/vendor/verbb/zen/src/services/Import.php(486): verbb\zen\elements\User::afterImport(Object(verbb\zen\models\ElementImportAction))
#12 /var/www/vendor/verbb/zen/src/queue/jobs/RunImport.php(56): verbb\zen\services\Import->runElementAction(Object(verbb\zen\models\ElementImportAction))
#13 /var/www/vendor/yiisoft/yii2-queue/src/Queue.php(243): verbb\zen\queue\jobs\RunImport->execute(Object(craft\queue\Queue))
#14 /var/www/vendor/yiisoft/yii2-queue/src/cli/Queue.php(162): yii\queue\Queue->handleMessage('26646687', 'O:30:"verbb\\zen...', '600', '1')
#15 /var/www/vendor/yiisoft/yii2-queue/src/cli/Command.php(146): yii\queue\cli\Queue->execute('26646687', 'O:30:"verbb\\zen...', '600', '1', '1')
#16 [internal function]: yii\queue\cli\Command->actionExec('26646687', '600', '1', '1')
#17 /var/www/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#18 /var/www/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#19 /var/www/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('exec', Array)
#20 /var/www/vendor/craftcms/cms/src/console/ControllerTrait.php(90): yii\console\Controller->runAction('exec', Array)
#21 /var/www/vendor/yiisoft/yii2/base/Module.php(552): craft\queue\Command->runAction('exec', Array)
#22 /var/www/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('queue/exec', Array)
#23 /var/www/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction('queue/exec', Array)
#24 /var/www/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('queue/exec', Array)
#25 /var/www/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest(Object(craft\console\Request))
#26 /var/www/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#27 /var/www/craft(23): yii\base\Application->run()
#28 {main} in /var/www/vendor/verbb/zen/src/queue/jobs/RunImport.php:94
Stack trace:
#0 /var/www/vendor/yiisoft/yii2-queue/src/Queue.php(243): verbb\zen\queue\jobs\RunImport->execute(Object(craft\queue\Queue))
#1 /var/www/vendor/yiisoft/yii2-queue/src/cli/Queue.php(162): yii\queue\Queue->handleMessage('26646687', 'O:30:"verbb\\zen...', '600', '1')
#2 /var/www/vendor/yiisoft/yii2-queue/src/cli/Command.php(146): yii\queue\cli\Queue->execute('26646687', 'O:30:"verbb\\zen...', '600', '1', '1')
#3 [internal function]: yii\queue\cli\Command->actionExec('26646687', '600', '1', '1')
#4 /var/www/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#5 /var/www/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#6 /var/www/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('exec', Array)
#7 /var/www/vendor/craftcms/cms/src/console/ControllerTrait.php(90): yii\console\Controller->runAction('exec', Array)
#8 /var/www/vendor/yiisoft/yii2/base/Module.php(552): craft\queue\Command->runAction('exec', Array)
#9 /var/www/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('queue/exec', Array)
#10 /var/www/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction('queue/exec', Array)
#11 /var/www/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('queue/exec', Array)
#12 /var/www/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest(Object(craft\console\Request))
#13 /var/www/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#14 /var/www/craft(23): yii\base\Application->run()
#15 {main} {"memory":66758992,"exception":"[object] (Exception(code: 0): Error: Call to a member function can() on null in /var/www/vendor/barrelstrength/sprout/src/datastudio/datasources/DataSources.php:76
Stack trace:
#0 [internal function]: BarrelStrength\\Sprout\\datastudio\\datasources\\DataSources::BarrelStrength\\Sprout\\datastudio\\datasources\\{closure}('BarrelStrength\\\\...')
#1 /var/www/vendor/barrelstrength/sprout/src/datastudio/datasources/DataSources.php(77): array_filter(Array, Object(Closure))
#2 /var/www/vendor/barrelstrength/sprout/src/datastudio/DataStudioModule.php(286): BarrelStrength\\Sprout\\datastudio\\datasources\\DataSources->getDataSourceTypes()
#3 /var/www/vendor/barrelstrength/sprout/src/datastudio/DataStudioModule.php(161): BarrelStrength\\Sprout\\datastudio\\DataStudioModule->getUserPermissions()
#4 [internal function]: BarrelStrength\\Sprout\\datastudio\\DataStudioModule->BarrelStrength\\Sprout\\datastudio\\{closure}(Object(craft\\events\\RegisterUserPermissionsEvent))
#5 /var/www/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Object(Closure), Object(craft\\events\\RegisterUserPermissionsEvent))
#6 /var/www/vendor/yiisoft/yii2/base/Component.php(650): yii\\base\\Event::trigger('craft\\\\services\\\\...', 'registerPermiss...', Object(craft\\events\\RegisterUserPermissionsEvent))
#7 /var/www/vendor/craftcms/cms/src/services/UserPermissions.php(107): yii\\base\\Component->trigger('registerPermiss...', Object(craft\\events\\RegisterUserPermissionsEvent))
#8 /var/www/vendor/craftcms/cms/src/services/UserPermissions.php(768): craft\\services\\UserPermissions->getAllPermissions()
#9 /var/www/vendor/craftcms/cms/src/services/UserPermissions.php(292): craft\\services\\UserPermissions->_filterOrphanedPermissions(Array, Array)
#10 /var/www/vendor/verbb/zen/src/elements/User.php(244): craft\\services\\UserPermissions->saveUserPermissions(7455777, Array)
#11 /var/www/vendor/verbb/zen/src/services/Import.php(486): verbb\\zen\\elements\\User::afterImport(Object(verbb\\zen\\models\\ElementImportAction))
#12 /var/www/vendor/verbb/zen/src/queue/jobs/RunImport.php(56): verbb\\zen\\services\\Import->runElementAction(Object(verbb\\zen\\models\\ElementImportAction))
#13 /var/www/vendor/yiisoft/yii2-queue/src/Queue.php(243): verbb\\zen\\queue\\jobs\\RunImport->execute(Object(craft\\queue\\Queue))
#14 /var/www/vendor/yiisoft/yii2-queue/src/cli/Queue.php(162): yii\\queue\\Queue->handleMessage('26646687', 'O:30:\"verbb\\\\zen...', '600', '1')
#15 /var/www/vendor/yiisoft/yii2-queue/src/cli/Command.php(146): yii\\queue\\cli\\Queue->execute('26646687', 'O:30:\"verbb\\\\zen...', '600', '1', '1')
#16 [internal function]: yii\\queue\\cli\\Command->actionExec('26646687', '600', '1', '1')
#17 /var/www/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#18 /var/www/vendor/yiisoft/yii2/base/Controller.php(178): yii\\base\\InlineAction->runWithParams(Array)
#19 /var/www/vendor/yiisoft/yii2/console/Controller.php(180): yii\\base\\Controller->runAction('exec', Array)
#20 /var/www/vendor/craftcms/cms/src/console/ControllerTrait.php(90): yii\\console\\Controller->runAction('exec', Array)
#21 /var/www/vendor/yiisoft/yii2/base/Module.php(552): craft\\queue\\Command->runAction('exec', Array)
#22 /var/www/vendor/yiisoft/yii2/console/Application.php(180): yii\\base\\Module->runAction('queue/exec', Array)
#23 /var/www/vendor/craftcms/cms/src/console/Application.php(91): yii\\console\\Application->runAction('queue/exec', Array)
#24 /var/www/vendor/yiisoft/yii2/console/Application.php(147): craft\\console\\Application->runAction('queue/exec', Array)
#25 /var/www/vendor/craftcms/cms/src/console/Application.php(122): yii\\console\\Application->handleRequest(Object(craft\\console\\Request))
#26 /var/www/vendor/yiisoft/yii2/base/Application.php(384): craft\\console\\Application->handleRequest(Object(craft\\console\\Request))
#27 /var/www/craft(23): yii\\base\\Application->run()
#28 {main} at /var/www/vendor/verbb/zen/src/queue/jobs/RunImport.php:94)"} 

How to reproduce

In a Craft website with both Zen and Data Studio plugins installed, have two databases with the same data ready to go.

  1. On DB 1, add a few users, then perform the export of it using Zen.

  2. Point Craft to use DB 2.

  3. Perform import of previously exported users using Zen.

Sprout Version

4.46.6

Craft Version

4.11.1

Database Type Version

MySQL 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant