Quick behavioral question:
If an extension is implementing a Session handler, and returns FAILURE from its PS_OPEN_FUNC(), will the extension receive subsequent PS_READ_FUNC()/PS_WRITE_FUNC() calls?
Also, if an extension returns FAILURE from its PS_OPEN_FUNC(), will the extension receive a PS_CLOSE_FUNC()/PS_DESTROY_FUNC() call?
If there are any docs on writing a Session handler, please let me know! I'm happy to RTFM...
Thx!
--E.
Quick behavioral question:
If an extension is implementing a Session handler, and returns FAILURE
from its PS_OPEN_FUNC(), will the extension receive subsequent
PS_READ_FUNC()/PS_WRITE_FUNC() calls?Also, if an extension returns FAILURE from its PS_OPEN_FUNC(), will the
extension receive a PS_CLOSE_FUNC()/PS_DESTROY_FUNC() call?
No to all, if you return FAILURE then it results in an E_ERROR
before the
point where the session state is marked as active, i.e. it's fatal, so no
further calls to anything will be made.
http://lxr.php.net/xref/PHP_TRUNK/ext/session/session.c#488
I'd argue that this shouldn't be fatal, but that's another topic for
another thread.
If there are any docs on writing a Session handler, please let me know!
I'm happy to RTFM...
Not officially as far as I am aware but someone else may know different.
There may be some unofficial resources on the net if your Google-fu is good
enough, a cursory search didn't turn anything up for me.
Thx!
--E.
From: Chris Wright
Sent: Wednesday, June 24, 2015 6:57 AM
Quick behavioral question:
If an extension is implementing a Session handler, and returns FAILURE from its
PS_OPEN_FUNC(), will the extension receive subsequent PS_READ_FUNC()/PS_WRITE_FUNC() calls?Also, if an extension returns FAILURE from its PS_OPEN_FUNC(), will the extension
receive a PS_CLOSE_FUNC()/PS_DESTROY_FUNC() call?No to all, if you return FAILURE then it results in an
E_ERROR
before the point where
the session state is marked as active, i.e. it's fatal, so no further calls to anything
will be made.
Hunh. That's weird, because in a repro case, I am seeing the WinCache session handler
getting called back for PS_READ_FUNC() after returning FAILURE from PS_OPEN_FUNC().
Looks like coming through the SessionHandler::read(string id) method is continuing to call
PS(default_mod)->s_read even though ->s_open failed. I believe this is because
the PS(mod_user_is_open) is being set to 1, despite the fact that the ->s_open failed.
http://lxr.php.net/xref/PHP_TRUNK/ext/session/mod_user_class.c#50
Do you want a bug opened on this?
Thank you for the pointer! Now that I see that the session extension is tracing
the error, I won't bother adding even more tracing to WinCache. However, it does
seem that extra error checking is required.
Thx!
--E.