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

Add redis as a valid option for global/session_save #1513

Merged
merged 1 commit into from
May 12, 2021

Conversation

rjocoleman
Copy link
Contributor

@rjocoleman rjocoleman commented Mar 29, 2021

This is a backwards incompatible change, so I don't think it's a good idea to merge it into 1.9.4.x, however 20.0 perhaps..?

So, this PR:

  1. Adds redis as an entry in the Core session selection switch statement.
  2. Removes the rewrite from Cm_RedisSession (to restate db when Cm_RedisSession is enabled)
  3. Enables Cm_RedisSession

The impact of this is in local.xml global/session_save will accept both db and redis as valid values.

The reason this is backwards incompatible is Cm_RedisSession used to rewrite and replace the db handler (if Cm_RedisSession was set to enabled/active in its module config.
Thus if merged Cm_RedisSession users will revert to DB for session storage.

Description (*)

This was mentioned here (among other places): #379 (comment)

Related Pull Requests

Fixed Issues (if relevant)

Manual testing scenarios (*)

  1. change local.xml <global><session_save> to redis
  2. configure local.xml redis_session
  3. Create a session with something clearly in it, e.g. add items to the cart and verify they are there after a page load (session is valid)
  4. use redis-cli FLUSHALL (etc) to drop clear the redis database (this will clear the whole redis db so don't run it on something you care about)
  5. Verify session is gone e.g. cart is now empty

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)

@github-actions github-actions bot added Component: Cm/RedisSession Relates to Cm_RedisSession Component: Core Relates to Mage_Core labels Mar 29, 2021
@colinmollenhour
Copy link
Member

Thanks for the PR! It would probably require some care in the future not to clobber your changes when updating the module but updates are also quite rare.. :) I'm in favor for 20.x to make it enabled out of the box and hence a little easier to configure.

@kkrieger85 kkrieger85 merged commit 4bfd347 into OpenMage:20.0 May 12, 2021
@github-actions
Copy link
Contributor

Unit Test Results

1 files  ±0  1 suites  ±0   0s ⏱️ ±0s
0 tests ±0  0 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
6 runs  +4  6 ✔️ +4  0 💤 ±0  0 ❌ ±0 

Results for commit 4bfd347. ± Comparison against base commit 42988a6.

@tobiasdalhof
Copy link

tobiasdalhof commented Aug 27, 2021

This PR causes issues with Amasty_Fpc

<config>
    <modules>
        <Cm_RedisSession>
            <version>0.2</version>
        </Cm_RedisSession>
    </modules>
    <global>
        <models>
            <core_mysql4>
                <rewrite>
                    <session>Cm_RedisSession_Model_Session</session>
                </rewrite>
            </core_mysql4>
            <!-- This causes issues with Amasty_Fpc
            <cm_redissession>
                <class>Cm_RedisSession_Model</class>
            </cm_redissession>
            -->
        </models>
    </global>
</config>

@rjocoleman
Copy link
Contributor Author

rjocoleman commented Aug 27, 2021

Here's a patch.

diff --git a/app/code/local/Amasty/Fpc/Model/Fpc/Front.php b/app/code/local/Amasty/Fpc/Model/Fpc/Front.php
index bb83b66..cbd7e78 100644
--- a/app/code/local/Amasty/Fpc/Model/Fpc/Front.php
+++ b/app/code/local/Amasty/Fpc/Model/Fpc/Front.php
@@ -464,6 +462,10 @@ class Amasty_Fpc_Model_Fpc_Front extends Varien_Object
         }

         switch ($moduleName) {
+            case 'redis':
+                $sessionResource = new Amasty_Fpc_Model_Resource_Redis_Session();
+                $sessionResource->setSaveHandler();
+                break;
             case 'db':
                 if ($this->isModuleEnabled('Cm_RedisSession'))
                     $sessionResource = new Amasty_Fpc_Model_Resource_Redis_Session();

Amasty_Fpc has a few issues with OpenMage. It needs a session namespace patch too.

@tobiasdalhof
Copy link

@rjocoleman Thanks for the patch!

justinbeaty added a commit to justinbeaty/Cm_RedisSession that referenced this pull request Aug 3, 2022
colinmollenhour pushed a commit to colinmollenhour/Cm_RedisSession that referenced this pull request Aug 3, 2022
* Remove submodules

* Do not rewrite (ref: OpenMage/magento-lts#1513)

Co-authored-by: Justin Beaty <justin.beaty@gmail.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Component: Cm/RedisSession Relates to Cm_RedisSession Component: Core Relates to Mage_Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants