genecommerce / module-encryption-key-manager

Tooling to help generate and invalidate magento encryption keys
GNU Lesser General Public License v3.0
54 stars 14 forks source link

Manually editing the env.php Results in *almost* Unrecoverable State #45

Closed nrdevau closed 1 month ago

nrdevau commented 1 month ago

So, I'm still working through the specifics, but I thought I'd be clever and manually edit the env.php file to add in the new crypt key. Looks great, everything on the site still looks to be working, we're all good! :+1:

Then I tried doing anything else with the bin/magento CLI and I get this error. Note, I only see the bin/magento commands that show in the setup (when a Magento instance is not installed correctly), so I'm thinking something has corrupted the part of the code which checks if Magento is installed correctly.


In Serialize.php line 35:

  Unable to unserialize value.  

This is now an unrecoverable state from the context of my hosting provider, and I'm going to need to restore a backup

PS. I know this isn't really exactly related to this codebase, but I get the feeling that as a community provided module, this also doubles as a community support channel for re-encryption caveats/gotchas.

Someone somewhere else might try and skip the GUI and have the same pain, so I just wanted to raise it.

In a perfect world, maybe someone has already run into this and knows how to resolve without blowing the environment away...

convenient commented 1 month ago

I suspect this is why adobe now recommend putting the site into maintenance mode https://experienceleague.adobe.com/en/docs/commerce-admin/systems/security/encryption-key

I believe that if you have multiple processes ongoing, you'll get the config cache corrupted. The old version may be written to your caching backend during the time when the env.php is being updated.

I'll leave this open until the readme.md is updated to reflect this, that generating the encryption key on an active site theoretically could cause an issue.

this is similar to what @TuVanDev saw the other day i think so worth calling out

nrdevau commented 1 month ago

Was there a solution? I'm digging through generated files and it's not a fun time. Unfortunately (because I can't get to the root cause) this has now resolved itself. Must have been some cron which fixed it :man_shrugging:

Good thing I didn't follow the directions and disable crons first I guess :joy:

Good luck everyone else!

convenient commented 1 month ago

@nrdevau flush redis cache is the solution

nrdevau commented 1 month ago

I would also say we can close this, but @convenient as you say, having something in the readme would be good, the question is, what if someone doess something dumb and fails like I did, BUT disabled the cron? I guess we need to figure out which job would have fixed it.

Flush redis. Now we know what to put in the readme :) Legend!!!