Fix bug when session is not in-memory #3

Open
wants to merge 2 commits into from

2 participants

@fgabolde

Hello,

I had some problems with the plugin where the message would never be stored in the session hash, and when forced inside by hand, would never be dequeued either.

After a very rudimentary examination, it seems not to happen when the session setting is not set, or when it is set to Simple; but at $work we use YAML for very simple apps and more complex backends for the rest and the problem happened every time.

My guess is that

my $foo = session('foo');
modify_in_place($foo);

works for in-memory sessions because you're manipulating the reference directly; for YAML and other types the value returned by their implementation of retrieve() has likely just been deserialized, so you need to write it back.

Hopefully these changesets fix the problem.

fgabolde added some commits Sep 12, 2012
@fgabolde fgabolde Cloned unit tests, set session to Storable (resp. YAML).
Removed files with no failures.  The remaining seem to indicate that the plugin
does not work with not-in-memory session engines.
9de1a44
@fgabolde fgabolde Fix failing tests by saving the session after every change.
Some of the cases did not need changes, those usually manipulated the session
directly instead of session's return value.
7e85503
@polettix
Owner

Hi! Sorry for taking all this time to answer.

I think I independently run into the same problem using the Storable backend a little more than one month ago, so the version that is on CPAN since Sep. 23rd should be fine. Apart from a bug that I see now that I'm looking a it :(

I've been much lazier than you and I did not add tests, so I'll happily incorporate yours for the next release to come very soon.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment