[PHP-BUG] Bug #63379 [NEW]: Warning when using session_regenerate_id(TRUE) with a SessionHandler

2012-10-28 Thread avatar2004-php at yahoo dot fr
From: avatar2004-php at yahoo dot fr
Operating system: Gentoo
PHP version:  5.4.8
Package:  Session related
Bug Type: Bug
Bug description:Warning when using session_regenerate_id(TRUE) with a 
SessionHandler

Description:

It seems there's an issue with the SessionHandler implementation and
the way the destroy handler is invoked when using
session_regenerate_id(TRUE)

The problem seems to come from using the global "mod_user_is_open" in
the PS_SANITY_CHECK_IS_OPEN macro (in ext/session/mod_user_class.c).

The test script generates an undue warning:

Test script:
---
$handler = new SessionHandler();
session_set_save_handler($handler, TRUE); // or FALSE, doesn't matter

session_start();
session_regenerate_id(TRUE);

//session_write_close();

Expected result:

No warning

Actual result:
--
PHP Warning:  Unknown: Parent session handler is not open in Unknown on
line 0

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63379&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63379&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63379&r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=63379&r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=63379&r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=63379&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63379&r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=63379&r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=63379&r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=63379&r=support
Expected behavior:  https://bugs.php.net/fix.php?id=63379&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=63379&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=63379&r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=63379&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63379&r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=63379&r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=63379&r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=63379&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63379&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63379&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63379&r=mysqlcfg



Bug #63379 [Com]: Warning when using session_regenerate_id(TRUE) with a SessionHandler

2012-10-28 Thread avatar2004-php at yahoo dot fr
Edit report at https://bugs.php.net/bug.php?id=63379&edit=1

 ID: 63379
 Comment by: avatar2004-php at yahoo dot fr
 Reported by:avatar2004-php at yahoo dot fr
 Summary:Warning when using session_regenerate_id(TRUE) with
 a SessionHandler
 Status: Open
 Type:   Bug
 Package:Session related
 Operating System:   Gentoo
 PHP Version:5.4.8
 Block user comment: N
 Private report: N

 New Comment:

If I understand correctly and "mod_user_is_open" is just a global state 
parameter used by the SessionHandler instance, I was wondering why the check 
wasn't being done on "session_status" instead to conform with the rest of the 
session_* API ?


Previous Comments:
----
[2012-10-29 01:04:34] avatar2004-php at yahoo dot fr

Description:

It seems there's an issue with the SessionHandler implementation and
the way the destroy handler is invoked when using
session_regenerate_id(TRUE)

The problem seems to come from using the global "mod_user_is_open" in
the PS_SANITY_CHECK_IS_OPEN macro (in ext/session/mod_user_class.c).

The test script generates an undue warning:

Test script:
---
$handler = new SessionHandler();
session_set_save_handler($handler, TRUE); // or FALSE, doesn't matter

session_start();
session_regenerate_id(TRUE);

//session_write_close();

Expected result:

No warning

Actual result:
--
PHP Warning:  Unknown: Parent session handler is not open in Unknown on line 0






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63379&edit=1


Bug #63379 [Com]: Warning when using session_regenerate_id(TRUE) with a SessionHandler

2012-10-28 Thread avatar2004-php at yahoo dot fr
Edit report at https://bugs.php.net/bug.php?id=63379&edit=1

 ID: 63379
 Comment by: avatar2004-php at yahoo dot fr
 Reported by:avatar2004-php at yahoo dot fr
 Summary:Warning when using session_regenerate_id(TRUE) with
 a SessionHandler
 Status: Assigned
 Type:   Bug
 Package:Session related
 Operating System:   Gentoo
 PHP Version:5.4.8
 Assigned To:arpad
 Block user comment: N
 Private report: N

 New Comment:

Looking at the code, it feels like the very semantics of the mod_user_is_open 
flag are not exactly consistent.

The flag is a global, yet it is manipulated by instance code. Meaning if the 
user space code uses several handlers interchangeably, the result can quickly 
become confusing.

I suggest a decision should be made as to whether the SessionHandler is a 
stateless, thin wrapper for the handler calls in which case it should default 
to the same checks as the procedural API. Otherwise, the flag should really be 
an instance variable used to track the proper invocation sequence of the 
different callbacks and make sure THIS handler is open before calling dependent 
routines.

Adding an instance variable to the (base) class though is probably not worth 
it. The session management semantics are already defined by the procedural API 
which uses a global session state flag (session_status). If required for a 
handler implementation, the flag can simply be implemented in user space.

Just my 2c.


Previous Comments:

[2012-10-29 03:07:41] larue...@php.net

I mean, maybe only reset it in close handler?


[2012-10-29 03:07:08] larue...@php.net

is the reseting of user_is_open necessary?

diff --git a/ext/session/mod_user_class.c b/ext/session/mod_user_class.c
index 70d2f40..4edac28 100644
--- a/ext/session/mod_user_class.c
+++ b/ext/session/mod_user_class.c
@@ -121,7 +121,6 @@ PHP_METHOD(SessionHandler, destroy)
return;
}

-   PS(mod_user_is_open) = 0;
RETVAL_BOOL(SUCCESS == PS(default_mod)->s_destroy(&PS(mod_data), key 
TSRMLS_CC));
 }
 /* }}} */


[2012-10-29 01:14:11] avatar2004-php at yahoo dot fr

If I understand correctly and "mod_user_is_open" is just a global state 
parameter used by the SessionHandler instance, I was wondering why the check 
wasn't being done on "session_status" instead to conform with the rest of the 
session_* API ?

--------
[2012-10-29 01:04:34] avatar2004-php at yahoo dot fr

Description:

It seems there's an issue with the SessionHandler implementation and
the way the destroy handler is invoked when using
session_regenerate_id(TRUE)

The problem seems to come from using the global "mod_user_is_open" in
the PS_SANITY_CHECK_IS_OPEN macro (in ext/session/mod_user_class.c).

The test script generates an undue warning:

Test script:
---
$handler = new SessionHandler();
session_set_save_handler($handler, TRUE); // or FALSE, doesn't matter

session_start();
session_regenerate_id(TRUE);

//session_write_close();

Expected result:

No warning

Actual result:
--
PHP Warning:  Unknown: Parent session handler is not open in Unknown on line 0






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63379&edit=1