2009年2月25日星期三

Re: [fw-mvc] Zend_Controller_Action_Helper_Redirector killsthesession

http://framework.zend.com/issues/browse/ZF-5873 is now closed. The fix (and
tests) was added in rev 14164.

On Tue, 24 Feb 2009 13:13:15 +0100, Christer Edvartsen
<cogo@starzinger.net> wrote:
>
> I added an issue about this in the issue tracker:
>
> http://framework.zend.com/issues/browse/ZF-5873
>
> I have created a patch for the Zend_Controller_Action_Helper_Redirector
> class and a patch for the RedirectorTest.php that adds a testcase that
> tests the setting/getting of the option and attached it to the issue. I
> can
> apply the patches myself and commit if people agree to the solution.
>
> On Thu, 19 Feb 2009 13:32:12 +0100, Sebastien Crocquesel
> <cortex93@gmail.com> wrote:
>> Putting code in a dispatchLoopShutdown would not help at all, the script
>> exit/die in the redirectAndExit function.
>> So the only way to have some bits to be executed is the
>> register_shutdown_function.
>>
>> About session_write_close, this call is here to prevent a bug regarding
>> session persistence when redirecting. In some cases, when doing a
> redirect
>> the session variables may not be saved, and this method helps a lot with
>> loosing data in session.
>>
>> Regarding your problem, I think that adding an option to handle the case
>> when the session_close should not happen could be a good solution. The
>> default behavior would remain the same, that is calling the
> session_close.
>>
>> Sébastien Crocquesel
>>
>> 2009/2/18 Christer Edvartsen <cogo@starzinger.net>
>>
>>>
>>> As specified in the blog post I'm not interested in using Zend_Session.
>>>
>>> This post was more about why the Redirector helper actually kills the
>>> session, and if people thinks this is good practice. :)
>>>
>>>
>>> On Tue, 17 Feb 2009 16:55:01 -0800, Hector Virgen <djvirgen@gmail.com>
>>> wrote:
>>> > Also, if you're using flash messages, why not use the flash messenger
>>> > controller helper provided by Zend? It already handles all of the
>> session
>>> > stuff for you.
>>> >
>>> > Just be sure to write your message to the flash messenger before
>>> > redirecting:
>>> >
>>> > public function addAction()
>>> > {
>>> > // add code
>>> > $this->_helper->flashMessenger('Your post has been added.');
>>> > $this->_helper->redirector(/.../);
>>> > }
>>> >
>>> > I hope this helps :)
>>> >
>>> > -Hector
>>> >
>>> >
>>> > On Tue, Feb 17, 2009 at 4:51 PM, Hector Virgen <djvirgen@gmail.com>
>>> wrote:
>>> >
>>> >> Maybe it would help to place your "shutdown" code in a front
>> controller
>>> >> plugin inside dispatchLoopShutdown(). Otherwise your code might be
>>> > running
>>> >> too late.
>>> >>
>>> >> -Hector
>>> >>
>>> >>
>>> >>
>>> >> On Tue, Feb 17, 2009 at 2:11 PM, Christer Edvartsen
>>> > <cogo@starzinger.net>wrote:
>>> >>
>>> >>> Today I noticed that Zend_Controller_Action_Helper_Redirector kills
>> the
>>> >>> current session in the redirectAndExit() method, wether you use
>>> > Zend_Session
>>> >>> or not. Why does it do that?
>>> >>>
>>> >>> I happened to try to do some session related stuff in a shutdown
>>> > function
>>> >>> but it failed because I had redirected the client using the
>> Redirector
>>> >>> helper and the session was no longer available in my shutdown
>> function.
>>> > I
>>> >>> extended the redirector to skip the call to session_write_close()
>> but I
>>> >>> can't say I think it's correct behavior that an action helper
> closes
>>> > the
>>> >>> current session just like that.
>>> >>>
>>> >>> I wrote a post about my solution over at my blog:
>>> >>>
>>> >>>
>>> >
>>>
>>>
>>
>
http://cogo.wordpress.com/2009/02/17/zend_controller_action_helper_redirector-wants-to-kill-my-session/
>>> >>>
>>> >>> I think it should be an option for the Redirector to close the
>> session,
>>> >>> and it should be disabled by default. If more people agrees I can
>> write
>>> > a
>>> >>> patch and submit it.
>>> >>>
>>> >>> Thanks.
>>> >>>
>>> >>> --
>>> >>> Christer Edvartsen
>>> >>> cogo@starzinger.net
>>> >>> http://cogo.wordpress.com/
>>> >>>
>>> >>>
>>> >>
>>> --
>>> Christer Edvartsen
>>> http://cogo.wordpress.com/
>>>
>>>
> --
> Christer Edvartsen
> http://cogo.wordpress.com/
--
Christer Edvartsen
http://cogo.wordpress.com/

没有评论: