2

I've configured Redis to handle cache and sessions for Craft 3, and while cache configuration is working as expected, I had to disable session configuration due to the below error.

It fails on the method getAssetBundleFlashes

Are there any other settings (e.g. for PHP) that may be required?

Here is my Redis component config in config/app.php for Yii 2 (yes I've added the yii2-redis package to my composer file too).

return [
    'components' => [
        'redis' => [
            'class' => yii\redis\Connection::class,
            'hostname' => getenv('REDIS_HOSTNAME'),
            'port' => 6379,
            'database' => 0,
        ],
        'session' => [
            'class' => yii\redis\Session::class,            
        ],
        'cache' => [
            'class' => yii\redis\Cache::class,
        ],
    ],
];

And here is the stack trace:

An Error occurred while handling another error:
yii\base\UnknownMethodException: Calling unknown method: yii\redis\Session::getAssetBundleFlashes() in /srv/craft/vendor/yiisoft/yii2/base/Component.php:300
Stack trace:
#0 /srv/craft/vendor/craftcms/cms/src/web/View.php(896): yii\base\Component->__call('getAssetBundleF...', Array)
#1 /srv/craft/vendor/craftcms/cms/src/web/View.php(818): craft\web\View->registerAssetFlashes()
#2 /srv/craft/vendor/yiisoft/yii2/views/errorHandler/exception.php(526): craft\web\View->endBody()
#3 /srv/craft/vendor/yiisoft/yii2/base/View.php(336): require('/srv/craft/vend...')
#4 /srv/craft/vendor/yiisoft/yii2/base/View.php(254): yii\base\View->renderPhpFile('/srv/craft/vend...', Array)
#5 /srv/craft/vendor/yiisoft/yii2/web/ErrorHandler.php(266): yii\base\View->renderFile('/srv/craft/vend...', Array, Object(craft\web\ErrorHandler))
#6 /srv/craft/vendor/yiisoft/yii2/web/ErrorHandler.php(126): yii\web\ErrorHandler->renderFile('@yii/views/erro...', Array)
#7 /srv/craft/vendor/craftcms/cms/src/web/ErrorHandler.php(156): yii\web\ErrorHandler->renderException(Object(yii\base\UnknownMethodException))
#8 /srv/craft/vendor/yiisoft/yii2/base/ErrorHandler.php(111): craft\web\ErrorHandler->renderException(Object(yii\base\UnknownMethodException))
#9 /srv/craft/vendor/craftcms/cms/src/web/ErrorHandler.php(71): yii\base\ErrorHandler->handleException(Object(yii\base\UnknownMethodException))
#10 [internal function]: craft\web\ErrorHandler->handleException(Object(yii\base\UnknownMethodException))
#11 {main}
Previous exception:
yii\base\UnknownMethodException: Calling unknown method: yii\redis\Session::getAssetBundleFlashes() in /srv/craft/vendor/yiisoft/yii2/base/Component.php:300
Stack trace:
#0 /srv/craft/vendor/craftcms/cms/src/web/View.php(896): yii\base\Component->__call('getAssetBundleF...', Array)
#1 /srv/craft/vendor/craftcms/cms/src/web/View.php(818): craft\web\View->registerAssetFlashes()
#2 /srv/craft/storage/runtime/compiled_templates/0b/0b226b9457e83d59f4ca4ab9c0a794a8e7489d0fa5850859e4263059d8eeeb71.php(63): craft\web\View->endBody()
#3 /srv/craft/vendor/twig/twig/lib/Twig/Template.php(390): __TwigTemplate_dcb3cad6f26dfdd9b0c18a08e2464625842a6825bf5d95797cfd4aff7f9d3ba1->doDisplay(Array, Array)
#4 /srv/craft/vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#5 /srv/craft/vendor/twig/twig/lib/Twig/Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#6 /srv/craft/vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)
#7 /srv/craft/storage/runtime/compiled_templates/92/928ab9c5030f542894551fd742424701943b57966d99233b0de96b7fd7dbc7fa.php(40): craft\web\twig\Template->display(Array, Array)
#8 /srv/craft/vendor/twig/twig/lib/Twig/Template.php(390): __TwigTemplate_566de35bd43d5ce1cf719a311929c2acf2baa3debb31cbeb7c6967ed2e3324cd->doDisplay(Array, Array)
#9 /srv/craft/vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#10 /srv/craft/vendor/twig/twig/lib/Twig/Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#11 /srv/craft/vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)
#12 /srv/craft/storage/runtime/compiled_templates/df/df104a4367ddd257c886d6ca86296f015495978d68f657dc29d28b6b8d55ad76.php(94): craft\web\twig\Template->display(Array, Array)
#13 /srv/craft/vendor/twig/twig/lib/Twig/Template.php(390): __TwigTemplate_9f1f09a6b58c9f64d0f79651ec01d22c48213d3eb6b8317580edaa5e0f09bc62->doDisplay(Array, Array)
#14 /srv/craft/vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#15 /srv/craft/vendor/twig/twig/lib/Twig/Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#16 /srv/craft/vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)
#17 /srv/craft/storage/runtime/compiled_templates/b9/b93d72fd3873b8f06d39c6630e8e2d8fcfadfd6798468d109266fec4e37c1dfe.php(32): craft\web\twig\Template->display(Array, Array)
#18 /srv/craft/vendor/twig/twig/lib/Twig/Template.php(390): __TwigTemplate_19451c5d966903f571459e857efabdca189708bebe8e4a3b3611e8d1061509a9->doDisplay(Array, Array)
#19 /srv/craft/vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#20 /srv/craft/vendor/twig/twig/lib/Twig/Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#21 /srv/craft/vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)
#22 /srv/craft/vendor/twig/twig/lib/Twig/Template.php(375): craft\web\twig\Template->display(Array)
#23 /srv/craft/vendor/twig/twig/lib/Twig/Environment.php(289): Twig_Template->render(Array)
#24 /srv/craft/vendor/craftcms/cms/src/web/View.php(305): Twig_Environment->render('dashboard/_inde...', Array)
#25 /srv/craft/vendor/craftcms/cms/src/web/View.php(352): craft\web\View->renderTemplate('dashboard/_inde...', '[<span class="s...')
#26 /srv/craft/vendor/craftcms/cms/src/web/Controller.php(113): craft\web\View->renderPageTemplate('dashboard/_inde...', '[<span class="s...')
#27 /srv/craft/vendor/craftcms/cms/src/controllers/DashboardController.php(135): craft\web\Controller->renderTemplate('dashboard/_inde...', Array)
#28 [internal function]: craft\controllers\DashboardController->actionIndex()
#29 /srv/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#30 /srv/craft/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#31 /srv/craft/vendor/craftcms/cms/src/web/Controller.php(74): yii\base\Controller->runAction('index', Array)
#32 /srv/craft/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('index', Array)
#33 /srv/craft/vendor/craftcms/cms/src/web/Application.php(238): yii\base\Module->runAction('dashboard/index', Array)
#34 /srv/craft/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('dashboard/index', Array)
#35 /srv/craft/vendor/craftcms/cms/src/web/Application.php(227): yii\web\Application->handleRequest(Object(craft\web\Request))
#36 /srv/craft/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#37 /srv/craft/web/index.php(30): yii\base\Application->run()
#38 {main}
1
  • Having the same issue using yii\redis\Session… Setting session.save_handler, session.save_path in php.ini works, however.
    – Tim Kelty
    Commented Jul 31, 2018 at 18:32

1 Answer 1

3

@boboldehampsink to the rescue: https://github.com/craftcms/cms/issues/3428


Update:

This article covers things really well. https://nystudio107.com/blog/the-case-of-the-missing-php-session

php ini config

[Session]
; http://www.php.net/manual/en/session.configuration.php#ini.session.save-handler
session.save_handler = redis
session.save_path = "tcp://127.0.0.1:6379"

configurable in /../craft/web/index.php

define('REDIS_HOSTNAME', getenv('REDIS_HOSTNAME') ?: 'localhost');
ini_set('session.save_handler', 'redis');
ini_set('session.save_path', 'tcp://'.REDIS_HOSTNAME.':6379');
1
  • Sorry, link is dead. Commented Nov 27, 2018 at 0:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.