jshirley/Catalyst-Plugin-MessageStack — pull request #2 by sartak (2012-06-08 20:48:31+00:00)
Title: Fix dropped messages on multiple redirects

I wrote a detailed explanation in 6cf60b8c07880bb599442cd13df3b51bf708c61a (and tests in 78c3d9591f49195b7beb0a250d60aac50ac3c7f1!) but here it is again for your instant gratification:

Catalyst::Plugin::Session::_save_flash compares object contents and
actually discards anything that matches what was there at the start
of the request. The symptom of this failure is if you redirect a few
times, messages will be lost.

If we have a controller action /permission_denied that adds a
message M, then redirects to /generic/index, which then redirects
to /real/index, then /real/index will not see that message M.
then the following bug occurs during the request to /generic/index:

1. Session pulls the saved messages out of the store, hashing its
contents to CAFEBABE.

2. MessageStack copies flash->{_messages} into stash->{messages}.

3. The controller action runs and redirects, without interacting
with stash->{messages} at all.

4. MessageStack notices the redirect and wants to preserve the
existing messages so it copies stash->{messages} into
flash->{_messages}.

5. Session decides whether to store the flash. It pulls saved
messages out of flash->{_messages}, hashes it, and sees that its
hash, CAFEBABE, matches what was there at the start of the
request, so drops it.

By explicitly telling Session to keep flash->{_messages}, it doesn't
compare hashes and doesn't drop flash->{_messages} in step 5.

よろしくお願いします