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

Cm_RedisSession: Fix Notice: Undefined offset: 0 #1705

Closed
wants to merge 1 commit into from

Conversation

justinbeaty
Copy link
Contributor

@justinbeaty justinbeaty commented Jun 26, 2021

Description (*)

After upgrading my local environment to v20.0.12 and setting <global><session_save> to redis, I could not log in to admin anymore, and would just get invalid form key. On my development box, I have developer mode enabled, and I get this error:

Notice: Undefined offset: 0  in /home/www-data/magento-root/htdocs/app/code/community/Cm/RedisSession/Model/Session.php on line 349

Previously, I was using this in my composer.json: "colinmollenhour/magento-redis-session": "^2.3", but I removed that and am using the version in this repo.

I am not sure if it is related to the upgrade in particular, or maybe there has always been this problem. I am on PHP 7.4.3. The problem is that hMGet returns an assoc array like array( 'data' => '', 'writes' => '') but list is expecting numerical keys.

@colinmollenhour Tagging you just for visibility.

Related Pull Requests

#1513

Edit: This is the same PR: #1254 -- probably was not reproducible for everyone because it requires Cm_Cache_Backend_Redis to be installed, see next comment.

Fixed Issues (if relevant)

Manual testing scenarios (*)

  1. Upgrade to v20.0.12
  2. Change local.xml <session_save> to redis
  3. Configure local.xml redis_session
  4. Attempt to login, receive invalid form key
  5. Enable developer mode
  6. Attempt to login, will receive the notice above

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 the Component: Cm/RedisSession Relates to Cm_RedisSession label Jun 26, 2021
@justinbeaty
Copy link
Contributor Author

justinbeaty commented Jun 26, 2021

I think I figured out what is going on here, it looks like it is because also use Cm_Cache_Backend_Redis.

In my composer.json, I put "colinmollenhour/cache-backend-redis": "^1.14",, which requires "colinmollenhour/credis": "*".

Now, Credis is loaded from vendor. However the version in my vendor folder is different than the one in this repo. The one in this repo has the following at line 964:

case 'hmget':
    $response = array_values($response);
    break;

Thus, it is already returning array_values. So this PR won't hurt anything since running an array twice through array_values is the same result.

Questions:

Is there anything else I should be aware of when using both this repo's Cm_RedisSession and Cm_Cache_Backend_Redis? Or is it better to use the composer version of Cm_RedisSession?

@Flyingmana
Copy link
Contributor

Interesting.

can you create a separate issue about the conflict of both versions and how the suggested way of handling it is?
Cant answer this spontanously, but its definitely something we should handle. And be it by making sure its not installed via composer.json

@justinbeaty
Copy link
Contributor Author

Hi @Flyingmana thanks for merging the other PR. I actually had made this PR before finding #1254, so I sort of laughed when I found the old one and it was the same exact fix. I'll make a new issue to discuss the conflict.

Closing this PR as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Cm/RedisSession Relates to Cm_RedisSession
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants