#18031 [Opn->Fbk]: PHP engine runs user-based read and disconnect functions when open return false

From: Date: Sun, 29 Sep 2002 18:46:06 +0000
Subject: #18031 [Opn->Fbk]: PHP engine runs user-based read and disconnect functions when open return false
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-20682@lists.php.net to get a copy of this message
 ID:               18031
 Updated by:       iliaa@php.net
 Reported By:      nbrandon@hotmail.com
-Status:           Open
+Status:           Feedback
 Bug Type:         Session related
 Operating System: Win ME
 PHP Version:      4.1.2
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip




Previous Comments:
------------------------------------------------------------------------

[2002-06-28 06:01:13] nbrandon@hotmail.com

Just looked at the code for php4/ext/session/session.c revision 1.310.

I'm no real coder but, I believe the area of code thats causing the
problem is

...
static void php_session_initialize(TSRMLS_D)
{
	char *val;
	int vallen;

	/* Open session handler first */
	if (PS(mod)->open(&PS(mod_data), PS(save_path), PS(session_name)
TSRMLS_CC) == FAILURE) {
		php_error(E_ERROR, "Failed to initialize session module");
		return;
	}
...

I believe the return should read

return FAILURE;

I could be completely way-off - but thats my 2-cents.

------------------------------------------------------------------------

[2002-06-27 19:51:50] nbrandon@hotmail.com

I have created my own session handler using both a function and class
based approach. On both occasions, when the "open" function returns a
failure - "return false;", PHP engine tries to run both the "read" and
"disconnect" functions. This causes a fatal error as shown below.

Fatal error: Call to undefined function: query() in
f:\cvs_dev\Neutec\website\www.xxxxxxxx.co.uk\site\include\DBSession.class.inc
on line 139

Fatal error: Call to undefined function: disconnect() in
f:\cvs_dev\Neutec\website\www.xxxxxxxx.co.uk\site\include\DBSession.class.inc
on line 109

On both lines, PHP is trying to connect to the database using a
database handler variable, and since the variable has not been
initialised (because the "open" function failed), these fatal errors
occur.

If the PHP engine could not "open" a session, then it should not try
and "read" or "disconnect" a session on exiting.

Full source code can be supplied on request.

Many Thanks
Nick




------------------------------------------------------------------------


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



Thread (6 messages)

« previous php.bugs (#20682) next »