Skip to content
New issue

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

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

Already on GitHub? # to your account

"Session does not exist in console request" gets thrown using the assetservice from a command line script #2798

Closed
lenvanessen opened this issue Apr 24, 2018 · 3 comments

Comments

@lenvanessen
Copy link

Description

The getUserTemporaryUploadFolder method tries to obfusticate the foldername by using a session ID, which is not present in a console request. Causing an exception to be thrown.

In this case this is using the a plugin.

Perhaps there is a better way to add a random obfustication key, without relying on session data, for instance when triggered by a console request this would be a huge benefit.

Exception 'craft\errors\MissingComponentException' with message 'Session does not exist in a console request.'

in xxx/vendor/craftcms/cms/src/console/Application.php:112

Stack trace:
#0 xxx/vendor/craftcms/cms/src/services/Assets.php(949): craft\console\Application->getSession()
#1 xxx/vendor/craftcms/cms/src/services/Assets.php(921): craft\services\Assets->getUserTemporaryUploadFolder(NULL)
#2 xxx/vendor/craftcms/cms/src/elements/Asset.php(188): craft\services\Assets->getCurrentUserTemporaryUploadFolder()
#3 xxx/vendor/craftcms/cms/src/base/Element.php(295): craft\elements\Asset::defineSources('index')
#4 xxx/vendor/craftcms/cms/src/services/ElementIndexes.php(73): craft\base\Element::sources('index')
#5 xxx/vendor/nerds-and-company/schematic/src/Mappers/ElementIndexMapper.php(66): craft\services\ElementIndexes->saveSettings('craft\\elements\\...', Array)
#6 xxx/vendor/nerds-and-company/schematic/src/Controllers/ImportController.php(88): NerdsAndCompany\Schematic\Mappers\ElementIndexMapper->import(Array, Array)
#7 xxx/vendor/nerds-and-company/schematic/src/Controllers/ImportController.php(49): NerdsAndCompany\Schematic\Controllers\ImportController->importFromYaml(Array)
#8 [internal function]: NerdsAndCompany\Schematic\Controllers\ImportController->actionIndex()
#9 xxx/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#10 xxx/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#11 xxx/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('index', Array)
#12 xxx/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('index', Array)
#13 xxx/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('schematic/impor...', Array)
#14 xxx/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('schematic/impor...', Array)
#15 xxx/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#16 xxx/craft(22): yii\base\Application->run()
#17 {main}

Additional info

  • Craft version: 3.0.3
@lenvanessen lenvanessen changed the title Session does not exist in console request get thrown on console command "Session does not exist in console request" gets thrown using the assetservice from a command line script Apr 24, 2018
@brandonkelly
Copy link
Member

Thanks for reporting!

@amityweb
Copy link

For info, this (or very similar) error still persists if the asset folder is empty. May not be a big deal though, as there are no assets to index, although would be good to not throw an error.

sh-4.2$ /opt/rh/rh-php70/root/bin/php craft index-assets/one dataSummary
Indexing assets in Data Summary ...
Done indexing assets in Data Summary.

Exception 'craft\errors\MissingComponentException' with message 'Session does not exist in a console request.'

in /home/mysite/public_html/vendor/craftcms/cms/src/console/Application.php:133

Stack trace:
#0 /home/mysite/public_html/vendor/craftcms/cms/src/services/AssetIndexer.php(344): craft\console\Application->getSession()
#1 /home/mysite/public_html/vendor/craftcms/cms/src/console/controllers/IndexAssetsController.php(166): craft\services\AssetIndexer->getMissingFiles('2c579a35-6ea7-4...')
#2 /home/mysite/public_html/vendor/craftcms/cms/src/console/controllers/IndexAssetsController.php(94): craft\console\controllers\IndexAssetsController->_indexAssets(Array, '', 0)
#3 [internal function]: craft\console\controllers\IndexAssetsController->actionOne('dataSummary', 0)
#4 /home/mysite/public_html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#5 /home/mysite/public_html/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#6 /home/mysite/public_html/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('one', Array)
#7 /home/mysite/public_html/vendor/craftcms/cms/src/console/Controller.php(199): yii\console\Controller->runAction('one', Array)
#8 /home/mysite/public_html/vendor/yiisoft/yii2/base/Module.php(528): craft\console\Controller->runAction('one', Array)
#9 /home/mysite/public_html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('index-assets/on...', Array)
#10 /home/mysite/public_html/vendor/craftcms/cms/src/console/Application.php(93): yii\console\Application->runAction('index-assets/on...', Array)
#11 /home/mysite/public_html/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('index-assets/on...', Array)
#12 /home/mysite/public_html/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#13 /home/mysite/public_html/craft(22): yii\base\Application->run()
#14 {main}

brandonkelly added a commit that referenced this issue Jul 14, 2019
@brandonkelly
Copy link
Member

@amityweb Thanks for reporting. Just fixed for the next release.

To get the fix early, change your craftcms/cms requirement in composer.json to:

"require": {
  "craftcms/cms": "dev-develop#ef2327fa616bbfd2d5b82d5f78a776011078add1 as 3.2.1",
  "...": "..."
}

Then run composer update.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants